# If you inadvertently remove a file of your working copy. Don't worry. Git are good at recovering old versions of files, such as:
$git checkout HEAD — data
# show what the file looks like in a certain branch.
$git show branch_name:file_name
# In newer versions of Git, git diff –ours is a synonym for git diff HEAD, because it shows the differences between "our" version and the merged version. Similarly, git diff MERGE_HEAD can be written as git diff –theirs. You can use git diff –base to see the combined set of changes since the merge base, which would otherwise be rather awkwardly written as:
git diff $(git merge-base HEAD MERGE_HEAD)
# While you are in the process of resolving a conflict, you can use some special git log options to help you figure out exactly where the changes came from and why. Try this:
$git log –merge –left-right -p
–merge shows only commits related to files that produced a conflict.
–left-right displays < if the commit was from the "left" side of the merge("our version", the one you started with), or > if the commit was from the "right" side of the merge("their" version, the one you're merging in).
-p shows the commit message and the patch associated with each commit.
If your repository were more complicated and several files had conflicts, you could also provide the exact file names you are interested in as a command line option, like this:
$git log –merge –left-right -p hello
# The -s option to git ls-files shows all the files with all stages. If you want to see only conflicted files, use the -u option instead.
# $ git checkout -m branch_name
If possible or if specifically requested with the -m option, Git attempts to carry your local change into the new working directory by performing a merge operation between your local modifications and the target branch.
# $ git reset –hard ORIG_HEAD
If you want to abort or discard the merge after it has finished(that is,after it has introduced a new merge commit), use the above command. Prior to beginning the merge operation, Git saves your original branch HEAD in the ORIG_HEAD ref for just this sort of purpose.
You should be very careful here, though. If you did not start the merge with a clean working directory and index, you could geet in trouble and lose any uncommitted changes you have in your directory.
# Just show what the file looks like in a branch.
$ git show branch_name:file_name
# The command for manipulating remotes is git remote. This operation introduces a few new settings in the .git/config file.