(Updated) Git cheatsheet (Mirroring, Merge, Rebase, Patch)

November 02, 2023

1. Copy your Git Repository to another (git mirroring)

Clone your repository

git clone --mirror https://github.com/exampleuser/repository-to-mirror.git

Set the push location to your mirror

cd repository-to-mirror.git
git remote set-url origin https://github.com/exampleuser/mirrored.git

Push to your mirror

git push --mirror

2. git merge with commit log

git merge --no-ff <branch>

Git - git-merge Documentation.)

3. Update feature branch with develop branch

git:(develop)git checkout feature-branch
git:(feature-branch)git rebase develop

4. Create a patch file from a commit

git format-patch -1 <commit>

Applying the patch

git apply --stat file.patch  # show status of the patch
git apply --check file.patch # check for error before applying
git am < file.patch          # apply the patch finally


Profile picture

Written by Yerin Hong who lives in London and works in the UK.