1.5 KiB
1.5 KiB
Git overview
config
git config --global user.email "email address" # only for label modified by
git config --global user.name "name"
git config --global color.ui auto
# general
git config --add <section>.<keyname> <value>
Commit history
git log
git log --stat
git log --patch
git log --follow <file name>
git reflog
git checkout <commit hash>
git checkout master
# show difference
git diff [first-branch]...[second-branch]
git show [commit]
ignore files, visual globally
touch .gitignore
~/.config/git/ignore # global
remove from tracking
git rm --cached <filename>
globally files to ignore, not visual for others
.gitignore file not required
.git/info/exclude
Branches
# create new branch
git branche <new branche name>
# or
git checkout -b <new-branch-name>
# switch
git checkout <branche name>
# merge into current
git merge <branch name>
# delete branche, after possible commit
git branch -d <branch name>
config in .git/
# add alias; different from bash alias
git config alias.st "status"
# usage
git st
Synchronize changes
# Downloads all history from remote
git fetch
# Combines remote tracking branch into current local branch
git merge
# Uploads all local branch commits
git push
# update local with remote
git pull == git fetch and git merge