• 2022-10-14
  • unique



keep fork up to date with upstream

# add the upstream with which we want to stay in sync
git remote add upstream https://github.com/whoever/whatever.git

git fetch upstream

# update the main branch to the upstream main commit
git checkout master

git rebase upstream/master

source: https://stackoverflow.com/a/7244456


create patche file

# go to main branch
git checkout main

# create patch file with all changes from branch 1-fix-some-bug
git format-patch 1-fix-some-bug --stdout > 1-fix-some-bug.patch

apply patch file

# go to branch you want to apply changes to
git checkout main

# apply patch file
git am ../1-fix-some-bug.patch

# see the changes
git log

source: https://www.git-tower.com/learn/git/faq/create-and-apply-patch/


reset single file to HEAD

git checkout HEAD -- some-file.txt

reset repo to HEAD

git reset --hard

reset repo to remote

git fetch origin
git reset --hard origin/main


change git history (last 10 commits)

git rebase -i HEAD~10