This is an old revision of the document!


Git Frequently Asked Questions

How do I tell git to ignore my local changes to file XYZ from the repository? Can I use .gitignore for that?

No, you cannot use .gitignore, because that only works on files that are not being tracked in the repository. If you want to tell git to ignore your local changes to file XYZ, use the following command:

$ git update-index --assume-unchanged XYZ

The command above sets a special flag for the file XYZ which makes git ignore any you did in your copy of the file. The flag remains in effect until you cancel it again with the following command:

$ git update-index --no-assume-unchanged XYZ

See man git-update-index for more details.

Is there a way to pull a version of the code as it was at a certain date?

You can check out what in the repository a week ago without a branch (it would be difficult to make/commit changes) with:

$ git checkout origin/master@{"1 week ago"}

The same thing, but creating a new local branch master_old with the content from 1 week ago:

$ git checkout -b master_old origin/master@{"1 week ago"}

Navigation

Wiki

Other

QR Code
QR Code git:faq (generated for current page)