Version Control
git
Config
git always uses --global option to config for all repos.
@example
git config –global user.name
git config –global http.proxy
git config –global core.editor
git config –global diff.tool vimdiff # Set vimdiff as the tool to edit diff
@end example
subsection Commit
@example
git init # Initialize an empty repo
git init –bare # Initialize a bare repo. It is useful for the dotfile projcet
git status # Show the changed and unstaged files
git add
git log # Show the comment log git log –oneline # Show the commit log in one line
git tag # List all tags
git tag -a v1.0 -m “msg” # Create an annotated tag
git show
git rebase -i
@end example
Branch
@example
git branch # List branches
git branch -a # List local and remote branches
git branch
git checkout
git diff # Differences (unstaged files) between now and HEAD
git diff
git stash # Save uncommitted changes into stash
git stash push -m “
git stash pop # Pop changes from stagh @end example
Remote
@example
git remote add
git clone
The following commands require git-remote-add
git push # Push this branch to the remote origin repo
git push
Submodule
@example git submodule update –init –recursive # Update all submodules:
git command for prompt in shell
git status –short | wc -l # Get the number of modified file in git
git branch –show-current # Show the name of current branch
git rev-list –count @@@{upstream@}..HEAD
# Count commits that local branch have but upstream does not
@end example
SSH Over HTTP for GitHub
@example cat « EOF » ~/.ssh/config Host github.com Hostname ssh.github.com Port 443 User git EOF @end example