git config --global user.email "[email]" git config --global user.name "[name]"configure user locally (single repository)
git config user.email "[email]" git config user.name "[name]"remember login (unix)
git config --global credential.helper cacheremember login (windows)
git config --global credential.helper wincredupdate credential cache timeout for single repo in seconds
git config credential.helper 'cache --timeout=300'change editor to vim
git config --global core.editor "vim"change line endings to windows based line endings:
git config --global core.autocrlf falsechange branch to push to (gerrit)
git config remote.origin.push HEAD:refs/for/mastershow colors
git config --global color.ui autoconfig file for ignoring files
.gitignore
[color] ui = false branch = false diff = false interactive = false status = false log = false
.gitattributes => defining attributes per path
Set the default behavior, in case people don't have core.autocrlf set.* text=autoConvert to os native line endings on checkout.
*.c text *.h textDeclare files that will always have CRLF line endings on checkout.
*.sln text eol=crlfDenote all files that are truly binary and should not be modified.
*.png binary *.jpg binarypossible attributes
text=auto => The default option. Let git decide. text eol=crlf => CRLF endings, even on OSX or Linux. text eol=lf => LF endings, even on windows binary => binary, do not change line endings
git fetch --all git clone [URL] git pull --all git push --allclone in specified directory
git clone [URL] [DIRECTORY]list remotes
document git remote -vadd new remote
git remote add origin [URL]migrate
git pull --all git remote set-url origin [NEW_URL] git push --allshow modified files
git statusshow lines changed in files
gir diffshow lines changed in files, ignore whitespace
git diff -wshow lines changed in files, don't use ANSI color codes
git diff --no-colorshow lines changed after files have been staged
git status -vshow contents of a single commit
git diff [hash]^..[hash]git commit, edit message in editor
git commitcommit with message
git commit -m "message"ammend changes to last commit
git commit --amendammend author (name, email)
git commit --amend --reset-authorundo last commit
git reset --hard HEAD~1rebase last 2 commits
git rebase -i HEAD~2pull and rebase
git pull --rebaserevert single file
git checkout filenamerevert a single file to a specified commit
git checkout [hash] [pah_to_file]
git reset --harddelete untracked files and directories
git clean -fdforce the current branch to the specified commit and drop all commits after it (careful!!!)
git reset --hard [commit]push to a specific remote branch
git push origin [branch]force overwrite a specific branch. (only if you know what you are doing)
git push origin development -f git push origin development --forceshow a listing of the latest commits
git logsearch through commit messages
git log --grep=[query]show latest commit message for branch
git show development
git branchlist remote branches
git ls-remote git branch -rcheckout local or remote branch
git checkout feature/IT-205create a local branch
git checkout -b [branch]create branch based on specified local or remote branch
git branch feature/nieuw --track /branch/to/base/ondelete local branch
git branch -d [branch]delete local and/or remote branch
git push origin --delete [branch]create remote branch for local branch
git push -u origin feature/smtpmerge [branch] onto current branch
git merge [branch]abort merge
git merge --abortcreate reverse commit of merge
git revert -m 1 [hash]cherry pick a single commit
git cherry-pick [hash]resolve merge conflict
git add -all git commit
git tagshow only tags matching a pattern
git tag -l "v1.8.5*"create a simple tag (commit pointer):
git tag v1.4-lwcreate an advanced tag with message:
git tag -a v1.4 -m "my version 1.4"push tag to origin
git push origin TAG_release_16
git stash git stash pushlist changes in stash
git stash listinspect changes in stash
git stash showapply stash changes to current commit
git stash applystash documentation
https://www.git-scm.com/docs/git-stash
ssh-keygen -t rsaenable access without login through environment variable (2.3.0)
GIT_SSH_COMMAND="ssh -i [rsa_file]" export GIT_SSH_COMMAND="ssh -i [rsa_file] -o StrictHostKeyChecking=no"enable access without login globally or per repo (2.10.0)
git config core.sshCommand "ssh -i ~/.ssh/id_rsa_example -F /dev/null"enable access without login through ~/.ssh/config
IdentityFile [file]use personal access token for github
git clone https://[user]:[token]@github.com/[owner]/[repo].git sed -i.bak 's|[^/]*@github.com|[user]:[token]@github.com|' $(find -type f -path '*/.git/config')
if git diff-index --quiet HEAD --; then # No changes else # Changes fi
sudo chown -R $USER .how to fix "You must edit all merge conflicts and then mark them as resolved using git add"This happens because when fixing a conflict, you removed all code in the patch beeing applied to the branch you are rebasing on.If you are sure you have added all your changes
git rebase --skip