More Git Recipes
Categories: [ IT/Git ]
Resolve a binary file conflict with Git
Found on lostechies.com
In case of conflict with a binary file during a merge, you have two choices for resolving it:
- Use your own version:
git add thefile
- Use the other version:
git checkout --theirs -- thefile; git add thefile
Then commit the changes.
Show the content of a deleted file
Found on stackoverflow.com
git show commitid:path/to/file
The trick here is that one must use the full path to the file (relatively to the repository's root)
Restore a deleted file in a Git repo
Found on stackoverflow.com
Find the last commit where the file was deleted:git rev-list -n 1 HEAD -- thefileThen checkout the file from the commit before that:
git checkout commitid -- thefile