-
Notifications
You must be signed in to change notification settings - Fork 33
Git Guide
aschey-forpeople edited this page Apr 30, 2025
·
2 revisions
- Should be descriptive
- Generally, try to commit often
- Look before you commit -
git status
-
Creates a separate commit - even if there are no conflicts
-
Merge commits are "special" because they have two parent commits
-
Resolve conflicts once at the very end
-
Rewrites history
- If a PR is already open, GitHub will show the diff after a force push
-
Replaces old timestamps
-
Don't do this if more than one person is working on a branch
-
Use
git push --force-with-lease
instead ofgit push --force
- this prevents overwriting work on the remote branch that you don't have locally
-
Risk of losing changes if conflicts occur
-
git reflog
may be able to save you
-
-
Commits are replayed on top of the current branch - resolve conflicts one commit at a time
-
git rebase
andgit rebase --continue
- can be time consuming if you have a lot of commits to go through
-
-
git rebase -i
- interactive
- Look before you commit
- Rebuild
- Look at what's in the source branch in a different window
- When in doubt, accept both and fix it manually
- Another option - create a fresh branch off of
master
, cherry pick commits from your old branch
- Example:
- Good for moving a commit from one branch to another
- Example: cherry-picking commit
f
-
Before
-
After
-
- Creates a new commit
- Be careful if reverting a merge - https://www.kernel.org/pub/software/scm/git/docs/git-revert.html
- "Reverting a merge commit declares that you will never want the tree changes brought in by the merge. As a result, later merges will only bring in tree changes introduced by commits that are not ancestors of the previously reverted merge. This may or may not be what you want."
-
git revert abc1234
- revert commitabc1234
- Erases an existing commit
-
git reset abc1234
- remove all commits until we reachabc1234
-
git reset --hard HEAD~1
remove latest commit and wipe all changes -
git reset --soft HEAD~1
remove latest commit and keep changes
(Images courtesy of Atlassian)
- Home
- For BFD Users
- Making Requests to BFD
- API Changelog
- Migrating to V2 FAQ
- Synthetic and Synthea Data
- BFD SAMHSA Filtering