Hosts: How am I supposed to use and update this repo?

Created on 27 Feb 2017  路  4Comments  路  Source: StevenBlack/hosts

I've been using this on and off for a while, but I'm not sure how I am supposed to get updates.

If I clone the repo it states that I should run the updateHostsFile.py script. So, I run it and it modifies the hosts file at the root of the repo, which does not allow me to pull new changes anymore:

$ git pull
error: Cannot pull with rebase: You have unstaged changes.

No matter, I can just checkout the hosts file and pull again.

$ git checkout hosts

However, when I start to add customizations to the myhosts file and the whitelist file, I run into the same problem.

$ git pull
error: Cannot pull with rebase: You have unstaged changes.

Now, I do not want to check out these files because I will lose my changes. So, my current workflow is something like:

  1. Make a manual backup of myhosts
  2. Make a manual backup of whitelist
  3. Reset all changes to the repo git checkout .
  4. Pull new changes
  5. Restore myhosts from backup
  6. Restore whitelist from backup
  7. Run the update script again

And of course, I have to go look up the all of the options and flags because I've forgotten them:

python updateHostsFile.py \
  --replace \
  --backup \
  --noupdate \
  --extensions gambling porn social

Please tell me there is a better way :)

Most helpful comment

The easiest way to keep local changes that I've found is:

git checkout -- hosts readmeData.json
git stash
git pull
git stash pop

That places the blacklist and myhosts file into a stash that you can pop after pulling the rest of the files down.

All 4 comments

Before you pull from this repo, execute this:

git reset --hard

Thereafter pulling will be fine.

The easiest way to keep local changes that I've found is:

git checkout -- hosts readmeData.json
git stash
git pull
git stash pop

That places the blacklist and myhosts file into a stash that you can pop after pulling the rest of the files down.

@meinhimmel and @jish I swear by the pull and push bash commands that come with git-friendly. These have git rebase baked-in and I can't overstate the usefulness of these two simple, elegant commands. The branch command in git-friendly is useful as well.

Edit: I just submitted git-friendly to Hacker News.

Closing.

Was this page helpful?
0 / 5 - 0 ratings