- Git from the Bottom Up
- Using Git (GitLab Docs)
- Using Git Effectively
- A beginner's guide to Git version control (HN)
- Working with Git Repositories (Codeberg)
- Git command reference (Microsoft)
- Git commands overview (Git Tower)
- Git quick reference (Fedora)
- Git Glossary
- Mercurial for Git users
- A Plumber's Guide to Git
- Git FAQ
- Git by example
-
2.47: Incremental multi-pack indexes, VSC as merge tool, new global config options
-
2.38: Rebase dependent branches with
--update-refs -
2.34: Sparse index, new default merge strategy
ort -
2.33: merge-ort - a new merge strategy
-
2.29: Experimental SHA-256 support
-
2.28:
init.defaultBranch, Bloom filters -
2.26: network fetch protocol 2 now default, config tricks
-
2.25: "partial clones", Sparse checkouts (
git sparse-checkout) -
2.24: Feature macros, Commit graphs by default
-
2.23:
git switch,git restore -
GitHub: Highlights from Git
- Getting Git right
- GitHub: Using Git
- Atlassian Git Tutorial
- Howto teach Git (HN comments)
- Microsoft Docs: Introduction to Git
- Deep dive into Git: Git objects, Git refs, Some useful Git commands, 10 useful Git commands
- Mary Rose Cook: Git in 600 words, Git from the inside out (video)
- Die vielfältigen Möglichkeiten von Git: Teil 1, Teil 2
- Learn Git Branching
- Git Immersion -- A guided tour that walks through the fundamentals of Git
- Git Command Explorer
- Idiot Proof Git (HN)
gitignore - Specifies intentionally untracked files to ignore
- Patterns to ignore in all situations:
$XDG_CONFIG_HOME/git/ignore/$HOME/.config/git/ignore- specified/overwritten by
core.excludesFile(gitconfig)
- specified/overwritten by
- Atlassian: .gitignore
- How to squash commits in Git
- Squashing your Pull Requests
git rebase -v -i main|master
- Resolving a merge conflict using the command line
- Atlassian: Git merge conflicts
- Resolving conflicts with git-rerere
- Merge conflicts in package-lock.json:
- Manually fix conflicts in
package.json - Run
npm install --package-lock-only
- Manually fix conflicts in
- githooks
- husky - Git hooks made easy
- https://github.com/okonet/lint-staged - Run linters against staged git files
$ cd .git/hooks$ mv pre-commit.sample pre-commit$ vim pre-commit$ chmod +x pre-commit
- frontaid Git CLI Tools
- delta - A viewer for Git and diff output
- difftastic - structural diff tool that compares files based on their syntax
- Jujutsu VCS - Git-compatible DVCS
- Tig - text-mode interface for Git
- lazygit - simple terminal UI for Git commands written in Go
- GitUI
- Vim style Key Config
$ git config --global user.name "[name]"
$ git congig --global user.email "[email address]"
$ git config --global gpg.format ssh
$ git config --global user.signingkey <KEY>
$ git config --global init.defaultBranch main
$ git config --global log.date iso8601
$ git config --global core.editor helix
$ git config --global core.autocrlf input
$ git config --global diff.tool meld
$ git config --global difftool.prompt false
$ git config set merge.tool vscode
$ git config --global merge.tool vimdiff
$ git config --global merge.conflictStyle zdiff3
$ git config --global mergetool.prompt false
$ git config --global commit.verbose true
$ git config --unset user.nameGit aliases
$ git config --global alias.ci commit
$ git config --global alias.ciam "commit --all --message"
$ git config --global alias.st statusSpecify how to reconcile divergent branches
$ git config pull.rebase false # merge (the default strategy)
$ git config pull.rebase true # rebase
$ git config pull.ff only # fast-forward onlyAdd --global to set default preference for all repositories.
Pass --rebase, --no-rebase, or --ff-only on the command line to override
configured default per invocation.
Edit configuration
Open editor to modify config file; either --system, --global, or repository (default)
$ git config --global --edit
- Dealing with line endings
- Signing your work
- Vertrauen durch Verifizierung: Commit-Signierung in Git (SSH)
- Configure fileMode (old mode != new mode)
$ git config --global core.fileMode false
- Git in Bash
- Git in Zsh
- git-prompt.sh
- path in Fedora:
/usr/share/git-core/contrib/completion/git-prompt.sh
- path in Fedora:
GIT_PS1_SHOWDIRTYSTATE=1: * unstaged changes, + staged changes
GIT_PS1_SHOWUNTRACKEDFILES=1: % untracked files
GIT_PS1_SHOWUPSTREAM="auto": < behind upstream, > ahead upstream, <> diverged, = no difference
~/.ssh/config
Host *.github.com
User git
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
$ git config --global gpg.program gpg2-
git add [ -p | --patch ] [ -i | --interactive ] [ -u | --update ]
-
git branch
-d,--delete: Delete a branch. The branch must be fully merged in its upstream branch, or inHEADif no upstream was set with--trackor--set-upstream-to.-D: Shortcut for--delete --force.-m,--move: Move/rename a branch and the corresponding reflog, e.g.git branch -m master main && git push -u origin main(Blog post)--sort=-committerdate: sort branches by date of their last commit (Blog post)
-
git checkout
- Argument disambiguation (
--) - reset a single file:
git checkout HEAD -- path/to/file
- Argument disambiguation (
-
git switch
- create new orphan branch:
$ git switch --orphan <new-branch>. All tracked files are removed.
- create new orphan branch:
-
git commit -am "<commit_message>"
- Angular Commit Message Guidelines
- Conventional Commits
$ git commit -m "Paragraph 1" -m "Paragraph 2"
-
git stash
-
git tag
- Tutorial
$ git tag v2.0.0 # lightweight tag$ git tag -a v2.0.0 -m "Version 2.0.0"# annotated tag
$ git stash push
$ git switch main
$ git stash list
$ git stash pop
- Git Tower FAQ
- Undo last commit
git reset --hard HEAD~1(HEAD~1is the same asHEAD~)
- Undo last commit
git log - The good parts (HN thread)
$ git [log](http://www.git-scm.com/docs/git-log) -3 # Limit the number of commits to output.Revert changes to file(s)
$ git checkout -- <file(s)>
Committed to wrong branch
$ git switch right-branch
$ git cherry-pick <commit-hash>
$ git switch -
$ git reset --hard HEAD~1Compare development branch with origin:
$ git fetch origin
$ git log origin/branchname..branchnameRename branch master to main (update local clone)
$ git branch --move master main
$ git fetch origin
$ git branch --set-upstream-to=origin/main main$ git add <files>
$ git commit --amend --no-edit # add <files> to previous (unpushed) commit without editing commit message$ git diff -b # --ignore-space-change (ignore changes in amount of whitespace)$ git diff --cached # Shows file differences between staging and the last file version (synonym: --staged)$ git diff preview master # Changes between the tips of the preview and the master branches.$ git checkout - # quickly jump back to your last git branch$ git remote -v # view current remotes- 15 Jahre Git: Die Versionsverwaltung hat Wurzeln geschlagen
- 3 Reasons to Upgrade Git For The First Time Ever
- Coding Career Advice: Using Git for Version Control Effectively
- Organizing multiple Git identities
- Confusing git terminology
- git rebase: what can go wrong? (HN)
- How I teach Git
- Better Git Conflicts with zdiff3
- Popular Git config options (HN)
- Scott Chacon (Gitbutler): Git Tips And Tricks