git

Diff between branches

git diff branch1..branch2

which is equivalent to

git diff branch1 branch2

Diff of one file path

git diff branch1..branch2 -- myfile.cs

Diff from a common ancestor

git diff [options] commitA...commitB [--] [path...]

This form is to view the changes on the branch containing and up to commitB, starting at a common ancestor of both commit.

git diff A...B

is equivalent to

git diff $(git merge-base A B) B

Rebase onto

git rebase --onto this-branch start-from-here this-branch

Delete a remote branch

git push -d remote-name branch-name

Delete a local branch

git branch -d branch-name

Delete a remote tracking branch

git branch -d -r remote-name/branch-name

Change url of remote

git remote set-url origin new-url

Fetch one branch from a remote

git fetch <remote_name> <branch_name>

Show the number of lines changed

git diff --stat
git diff --numstat

Tags

Show tags

git tag

Add a tag

git tag tagname

Push tag to remote

git push origin tagname

Branches

Create a branch and switch to it at the same time

git checkout -b iss53

Logging

git log --pretty=oneline
git log --graph --oneline --decorate --all