cheatsheet-git
Table of Contents
Cheatsheet GIT
Summary: Git hints, tips, oneliners and best practices.
Date: 8 December 2024
Note: There is now also an official git cheatsheet!
General
Check git repository size
git count-objects -vH
Combine fetch and merge to completely update a repository
git pull
Log & Diff
Show git log
git log # Show git log oneline - last 10 lines git log --oneline -n10
Show the files which have changed between the branch and master
git diff --name-only master..branchtocheck
Branches
Create and immediately checkout a branch
git checkout -b "#123456-add-dns-resolving"
Show all branches
git branch -a
Show all active branches
git ls-remote --heads origin
Merge changes from master branch, perform from inside the branch
git merge master
Git Remotes
Show remote
git remote -v
Update the remote “origin” with a new url in case of a rename of the repo or project
git remote set-url origin https://getshifting@dev.azure.com/getshifting/Infra/_git/infraplayground
Commits
Add and commit a new file
git add . git commit -m "Added new file"
Add and commit in 1 go for changed files
git commit -am "changed a file"
Co-Authoring / Pair coding commit message
Changed a couple of files Co-Authored-By: Sjoerd <sjoerd @ getshifting.com>
Do not trigger CI in Azure DevOps
***NO_CI***
Cherry-Pick
You can do a cherry pick to apply a specific commit from another branch. First look up the commit id, and once found, do a cherry pick and push the changes:
git cherry-pick 360f6268 git push # Or in one go git cherry-pick 360f6268; git push
This wiki has been made possible by:
cheatsheet-git.txt · Last modified: by 127.0.0.1
