0

I want to have two separate versions of a file: One on github and one on my local machine.

More specifically, how do I ignore a commit coming from the remote server. In this particular case, I modified the file on github, committed it, but I want it to not change on my local machine.

I put the readme file on .gitignore. Changed the file on github.

Made a commit

Fetched the commit on my local machine using VS2017. How do I "ignore" the commit. And keep the two versions separate.

Nathan Fowler
  • 561
  • 5
  • 19
  • 2
    That seems fundamentally opposed to the idea of distributed version control. Why do you think you want this? – jonrsharpe Apr 21 '19 at 21:20
  • This must be an [XY problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). What problem are you trying to solve that you think this is the answer? – ChrisGPT was on strike Apr 22 '19 at 00:08
  • As I stated, I wanted to have two separate versions of a readme file: One on github and one on my local machine. How do I do this using Git commands, rather than manually? (e.g. by doing the steps outlined above, putting the file on .gitignore) – Nathan Fowler Apr 22 '19 at 16:52
  • jonrsharpe: Because I want the local readme to have information specific to me, and I want the github readme to be public-facing. This seems like a common scenario even for distributed VC. – Nathan Fowler Apr 22 '19 at 16:55
  • @NathanFowler My answer precisely matches the "I modified the file on github, committed it, but I want it to not change on my local machine." use case. – VonC Apr 22 '19 at 18:28

1 Answers1

1

You can at least try:

git update-index --skip-worktree -- README.md

As I mentioned here, that would resist a git pull.
And you would keep a local version of README.md, different from the tracked one from GitHub.
I don't presume to know if it is a good idea or not, in your particular situation.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250