https://docs.freebsd.org/en/articles/committers-guide/#git-primer
Diff from a specific hash:
git diff b97a47e94662^!
Create a patch from a specific hash:
git format-patch b5711fa4a98^!
Preserving original author name, and tunning commit if it needs:
git am file.patch
git commit --amend
When was the branch branched ?
$ git show --summary `git merge-base working-branch-name main`
commit xxxxxx
Merge: yyyyy
Author: root
Date: Wed May 24 19:13:34 2023 +0000
Pull request #????: branch-xxx
Merge in xxx/yyy from branch-zzz to main
* commit 'xxxx'
blah.
When was that file detele?
git log --all -1 -- path/to/file
What version was patched:
git -C /usr/src rev-list --count --first-parent HEAD
patch?
Create a new branch:
git checkout -b new-branch
hack....
push changes:
git push origin -u new-branch
But now, need to get new commit from the origin:
git switch new-name
git fetch origin
git rebase
=> resolve conflict (and commit it!) then git rebase --continue
git push
Display all last commits to be squashed:
git log --pretty=oneline
Let’s use an example of 5 last commits here:
git rebase -i HEAD~5
First text editor that open:
- first line, kept the 'pick' keyword
- all others 4 lines: Replace 'pick' by 's' (squash) => save & exit
- Adapt the squashed commit message => save & exit
Now push back your rebase:
git push origin +branch-name
You’ve squashed a wrong commit, so your rebase need to be reverted.
git reset --hard origin/branch-name
From git webui: Fork freebsd/freebsd-ports
git clone [email protected]:ocochard/freebsd-ports.git
git clone [email protected]:ocochard/freebsd-src.git
cd freebsd-ports
git remote add upstream [email protected]:freebsd/freebsd-ports
Therminology:
- Origin = own fork
- upstream = FreeBSD official
- main = name of the main branch (was called 'master' previously)
git checkout -b BSDRP
=> hack
git commit
git push -u origin BSDRP
=> hack
git commit
git push
git checkout main
git pull
git checkout branch-name
git rebase main
git push -f
git checkout BSDRP
#git rebase main
git pull --rebase upstream/main ?, this one is equivalent to git fetch + git rebase origin/master
git push
Or sync WIP branch with the main:
git checkout WIP
git rebase master WIP
git remote add motoprogger [email protected]:motoprogger/FreeVRRPd.git
git checkout <branch>
git fetch motoprogger
git cherry-pick <commit-hash>
git push <your-fork-alias>
git tag -a v1.992 -m "Releasing version v1.992"
git push origin v1.992
Local and remote:
git branch -d branch-name
git push origin -d branch-name
@{u} is shorthand for upstream branch
git reset --hard @{u}