git cheat

how to pull from remote git repository and override the changes in my local repository

git fetch origin
git reset --hard origin/{your branch}

Unstage all the changes

You can unstage files from the index using

git reset HEAD -- path/to/file

Just like git add, you can unstage files recursively by directory and so forth, so to unstage everything at once, run this from the root directory of your repository:

git reset HEAD -- .

Merging changes and stashing

Stashing acts as a stack, where you can push changes, and you pop them in reverse order. To stash type:

git stash

Do the merge, and then pull the stash:

git stash pop

checking stashed changes

Check status (git status) of your repository. Every unmerged file (after you resolve conficts by yourself) should be added (git add), and if there is no unmerged file you should git commit

The modifications stashed away by this command can be listed with git stash list, inspected with git stash show

show [] Show the changes recorded in the stash as a diff between the stashed state and its original parent. When no is given, shows the latest one. By default, the command shows the diffstat, but it will accept any format known to git diff (e.g., git stash show -p stash@{1} to view the second most recent stash in patch form). So, to view the content of the most recent stash, run

git stash show -p

To view the content of an arbitrary stash, run something like

git stash show -p stash@{1}

error: You have not concluded your merge (MERGE_HEAD exists).