[color] branch = auto diff = auto status = auto [color "branch"] current = yellow reverse local = yellow remote = green [color "diff"] meta = yellow bold frag = magenta bold old = red bold new = green bold [color "status"] added = yellow changed = green untracked = cyan
[color] ui = true [core] whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol
[alias] st = status ci = commit br = branch co = checkout df = diff lg = log -p
Sets your email for commit messages.
git config user.email johndoe@example.com
Sets your name for commit messages.
git config user.name 'John Doe'
Tells git-branch and git-checkout to setup new branches so that git-pull(1) will appropriately merge from that remote branch. Recommended. Without this, you will have to add –track to your branch command or manually merge remote tracking branches with “fetch” and then “merge”.
git config branch.autosetupmerge true
You can add “–global” after “git config” to any of these commands to make it apply to all git repos (writes to ~/.gitconfig).
Create local branch
git branch search
Push local branch
git push origin search
Delete local branch
git branch -d search
Delete remote branch from remote repo (permanently)
git push origin :search
Remove remote branch from local repo
git branch -d -r origin/search
Rename local branch
git branch -m search dev/search
Track a single remote branch as a local branch
git checkout —track -b foo origin/foo
Pushing all local branches to remote, creating new remote branches as needed
git push —all origin
Merge a branch into the current branch
git merge foo
Merge from another local git repository
git pull ../another-git-repo/ master
Create a “bare” git repo (just the contents of the .git folder) in the current directory
git --bare init
Add a remote
git remote add origin git@github.com:jschementi/foo.git
Move all your commits in a “topic” branch to the top of the log
git rebase master topic
Interactively rebase (reorder, combine, and delete commits)
git rebase --interactive master topic
Move all uncommitted commits on the current branch to the top of the log
git rebase
Delete the current commit
git reset --hard HEAD~1
Rewrite all commits to move entire repository into a sub-directory
git filter-branch --prune-empty --tree-filter ' if [ ! -e bank ]; then mkdir -p bank; git ls-tree --name-only $GIT_COMMIT | xargs -I files mv files bank; fi'
Rewrite all commits to change the email address for an author
git filter-branch --commit-filter ' if [ "$GIT_COMMITTER_NAME" = "Jimmy Schementi" ]; then # GIT_COMMITTER_NAME="<New Name>"; # GIT_AUTHOR_NAME="<New Name>"; # GIT_COMMITTER_EMAIL="<New Email>"; GIT_AUTHOR_EMAIL="[email protected]"; fi; git commit-tree "$@";' HEAD
Create a tag at the current commit
git tag -a this-is-a-tag
Push tags
git push --tags