Keywords: Source Code Management (SCM), Codebase, Version Control System (VCS)
- Changing Your Git Author Identity
- Guideline
- Wiki
- git-flow
- Version Control Systems: Distributed vs. Centralized
- Apache Subversion (SVN)
- Fossil
- Mercurial
# Using Homebrew
brew install git
# Using APT
sudo apt update
sudo apt -y install git
# Using YUM
yum check-update
sudo yum -y install git
# Using APK
sudo apk update
sudo apk add git
# Using Zypper
sudo zypper refresh
sudo zypper install -y git-core
# Using Chocolatey
choco install -y git
# Initialize
git init
# or, define branch
git init --initial-branch='develop'
# Create
git tag <version>
# Describe
git tag -a <version> -m <message>
# Push with Tags
git push origin master --tags
# List
git tag -l
# Checkout
git checkout tags/<version>
# Remote
git ls-remote --tags
# Delete
git tag -d <version>
# Remote
git push --delete origin <version>
# Update Index
git update-index --assume-unchanged <file>
git update-index --no-assume-unchanged <file>
# Prevent to receive changed files
git update-index --no-assume-unchanged <file>
# Ignore local changed files
git update-index --assume-unchanged <file>
# List files with `assume-unchanged`
git ls-files -v | grep '^h'
/cache/*
!/cache/.gitkeep
/logs/*
!logs/.gitkeep
git branch --no-color | \
grep -v 'master\|stable\|main' | \
xargs git branch -d
git branch --merged | \
egrep -v '(^\*|main)' | \
xargs git branch -d
#
git tag -am 'Version 1.0.0' v1.0.0 master
git tag -am 'Version 1' v1 master
#
git tag -am 'Version 1.0.1' v1.0.1 master
git tag -am 'Version 1' --force v1 v1.0.1
#
git push --follow-tags
-
Fast Forward Merge
- No new commits on the base branch
- No merge commit on the base branch when merged
- Provides a linear history
git rebase
-
Recursive Merge
- New commits on the base branch
- A merge commit is created on the base branch
- Merge commit has 2 parents with a true diverged history
git merge --no-ff
# Using Antigen
antigen bundle git
#
git remote -v
#
git remote remove origin <url>
git remote add origin <url>
# or, using set-url
git remote set-url origin <url>
# Creating a branch from a commit
git branch <branch-name> <hash>
# Creating a branch from a tag
git branch <branch-name> <tag-name>
#
code --install-extension mhutchie.git-graph
#
jq '."recommendations" += ["mhutchie.git-graph"]' "$HOME"/.vscode/extensions.json | sponge "$HOME"/.vscode/extensions.json
# Globally
jq '."search.exclude"."**/.git" |= true' "$HOME"/.vscode/settings.json | \
sponge "$HOME"/.vscode/settings.json
# Locally
jq '."search.exclude"."**/.git" |= true' "$PWD"/.vscode/settings.json | \
sponge "$PWD"/.vscode/settings.json
# Globally
jq '."files.exclude"."**/.git" |= false' "$HOME"/.vscode/settings.json | \
sponge "$HOME"/.vscode/settings.json
# Locally
jq '."files.exclude"."**/.git" |= false' "$PWD"/.vscode/settings.json | \
sponge "$PWD"/.vscode/settings.json
git for-each-ref --sort=committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)'
git for-each-ref \
--sort=-committerdate refs/heads/ \
--format='%(committerdate:short) %(authorname) %(refname:short)'
# Using Oh My Zsh
sed -ri 's/^plugins=\((.*)\)/plugins=\(\1 git\)/g' ~/.zshrc
source ~/.zshrc
rm ~/.zcompdump*
# Current
git describe --tags
#
git describe --tags --abbrev=0
#
git describe --tags | sed 's/^v//'
#
git describe --tags | cut -d - -f 1 | sed 's/^v//'
# Commit
git commit -sm '<message>'
# Ammend
git commit --amend --signoff
# Push
git push --force-with-lease
#
git clone --no-checkout <repo>
#
git checkout --orphan gh-pages
#
git clean -fdx
#
git push origin gh-pages
# Try disable Hooks
git config --unset core.hooksPath
Missing or invalid credentials.
TODO
error: cannot lock ref 'refs/remotes/origin/Feat/HAB-337': unable to resolve reference 'refs/remotes/origin/Feat/HAB-337'
TODO
error: cannot update the ref 'refs/remotes/origin/Feat/HAB-357': unable to create directory for '.git/logs/refs/remotes/origin/Feat/HAB-357': No such file or directory
mkdir ./.git/logs/refs/remotes/origin/Feat/HAB-357
Git: fatal: Unable to create '/path/to/project/.git/index.lock': File exists.
rm ./.git/index.lock
error: cannot lock ref 'refs/remotes/origin/fix/dbml': 'refs/remotes/origin/fix' exists; cannot create 'refs/remotes/origin/fix/dbml'
git remote prune origin
fatal: refusing to merge unrelated histories
git pull origin master --allow-unrelated-histories
SSL certificate problem: unable to get local issuer certificate
# Local
git config http.sslVerify false
# Or, global
git config --global http.sslVerify false
# Or, environment
GIT_SSL_NO_VERIFY=true git clone <repo>
Received HTTP code 502 from proxy after CONNECT
git config --unset http.sslVerify
error: RPC failed; result=22, HTTP code = 411
git config http.postBuffer 524288000
Output message after run git commit --amend
:
error: Terminal is dumb, but EDITOR unset
Please supply the message using either -m or -F option.
Solve this issue setting the core.editor
value:
git config --global core.editor <value>
Use
vim
,atom --wait
,subl -n -w
andmate -w
.
export GIT_EDITOR=vim
error: src refspec project does not match any.
error: failed to push some refs to 'project@xyz.tld:project'
git push -u origin master