Ted Felix has a very nice guide about Conflict Resolution in Git.

Git

Delete branch

git push origin :card-XXXX    # delete on remote
git branch -D card-XXXX       # delete sandbox branch

Fetch and track branch from Dingobats (dingobat) repository

git remote add dingobat git@github.com:dingobat/eSignatur.git
git fetch dingobat
git checkout card-XXXX        # card-XXXX is now available to you

Switching between branches with uncommitted changes

git stash                   # save changes in this card
git checkout card-XXXX      # new card
.
do work
.
commit
git stash pop               # fetch previously stashed
Stash works independently from branches. However when you pop the stash, whatever popped must be able to merge.

If sandbox copy is f*cked up

git checkout master
git branch -D master
git checkout -b master --track origin/master
git checkout card-XXXX
git rebase -i master
.
.
.
git push -f origin card-XXXX

Ignore local files

echo "UpgradeLog*" >> .gitignore
echo "_UpgradeReport_Files/" >> .gitignore
echo ".gitignore" >> .gitignore
git update-index --assume-unchanged .gitignore

New branch

git checkout -b card-XXXX
If the new branch is dependent on other branch:
git checkout card-YYYY             # parent branch
git rebase master
git push -f origin card-YYYY       # card-YYY contains commits from master
git checkout -b card-XXXX          # new branch
git rebase -i master and remove unwanted commits in card-XXXX from master. Use gitk to verify the commit chain.

Push to master

git push -f origin card-XXXX       # omit -f on first push

See previous version of file

git show HEAD~1:./Index.cshmtl
The number (~1) after HEAD denotes which version. The file path after : must be full. However, to see version of a file in current directory full path is ./

Untrack file

git update-index --assume-unchanged [path] ...
git update-index --no-assume-unchanged [path]        # To start tracking the file again

Update from master

git checkout master                        # (if in branch)
git pull --ff-only rovsing master
git push origin master

Maintenance

git gc         # do once in a while (happens automatically in git gui)
git fsck       # lengthy process

Change commits

git checkout master
git pull
git checkout card-XXXX
git rebase -i master
Change the status from pick to edit on the commits you want to change.
do {
    git gui                        # unstage or commit what needs to be changed
    git rebase --continue
} while (commits_present)
git push -f origin card-XXXX

Use multiple SSH keys

  1. ssh-keygen, give a name which doesn't clash with whatever identities you have in .ssh. Move the keypair to ~/.ssh.
  2. Add the public key to your git account.
  3. Add to ~/.ssh/config:
    Host git-for-other
    	HostName github.com
    	User git
    	IdentityFile "/path/to/.ssh/other-identity-key"
    	IdentitiesOnly yes
    
  4. Remove existing origin from repository:
    cd $REPOSITORY
    git remote remove origin
    
  5. Add new origin:
    git remote add origin git@git-for-other:git-user/Repository.git
    

Installation on Windows

Install the Git SDK version. Then, after installation (in the prompt that opens):

    pacman -S --needed --force rsync

(For rsync support :-)