cheatsheet-git

Cheatsheet GIT

Summary: Git hints, tips, oneliners and best practices.
Date: 8 December 2024

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 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***
cheatsheet-git.txt · Last modified: by 127.0.0.1

Exception: Git command failed to perform periodic pull: From https://dev.azure.com/getshiftingcom/Documentation/_git/knowledge * branch main -> FETCH_HEAD There is no candidate for rebasing against among the refs that you just fetched. Generally this means that you provided a wildcard refspec which had no matches on the remote end.

Exception: Git command failed to perform periodic pull: From https://dev.azure.com/getshiftingcom/Documentation/_git/knowledge * branch main -> FETCH_HEAD There is no candidate for rebasing against among the refs that you just fetched. Generally this means that you provided a wildcard refspec which had no matches on the remote end.

An unforeseen error has occured. This is most likely a bug somewhere. It might be a problem in the gitbacked plugin.

More info has been written to the DokuWiki error log.