2024-11-08
Git
Do an empty commit:
git commit --allow-empty -m "Trigger Build"
Push to trigger a build of a PR:
git push -f origin feat-branch-name
Undo quickly
If quickly testing some unstaged changes on a file, the changes can be undone with:
git checkout <file>
Interactive add
Let’s say you want to sync one file from upstream.
cp ../upstream/file.txt .
Now you want to selectively stage changes. The best way is an interactive add:
git add -p file.txt
You can then say (n)o, (y)es or (d)iscard for specific hunks. You can also (s)plit hunks for finer-graind control and (e)dit to modify a change. Be careful not to make changes that will result in different line numbers, as this can get messy
Fork and pull
Submitting a PR when it turns out you don’t have write access…
Fork the repo that you probably should have forked to begin with.
Then add that as a remote (myfork
is arbitrary):
git remote add myfork git@github.com:user/repo.git
Now set that as an upstream and push your branch:
git push --set-upstream myfork cool-new-feature