-
Notifications
You must be signed in to change notification settings - Fork 3
Commit guidelines
Commits should be logical, atomic units of change that represent a specific idea. So, theoretically, it should be done for each solution for a problem.
For commit message guidelines, see link.
- Undoing a commit that exists on the remote (force push) could create big problems for your collaborators
- Undoing a commit on work that you only have locally is much safer
- Worse case: Drastic changes can cause Git to no longer recognise the projects as related.
- Common case: The "deleted" commit could be "undeleted" without any notification (could be a password, token, or large binary file).
git revert is the safest way to change history with Git. Instead of deleting existing commits, git revert looks at the changes introduced in a specific commit, then applies the inverse of those changes in a new commit. It functions as an "undo commit" command, without sacrificing the integrity of your repository's history. git revert is always the recommended way to change history when it's possible.
Moves the HEAD pointer and the branch pointer to another point in time, making it seem like the commits in between never happened.
- Maybe cause loss of work
- Useful when a commit includes sensitive information that must to be deleted
- Before
git reset:- Make sure to talk with your team about any shared commits
- Research the three types of reset to see which is right for you (--soft, --mixed, --hard)
- Commit any work that you don't want to be lost intentionally - work that is committed can be gotten back, but uncommitted work cannot
A log of every commit that HEAD has pointed to. Could be use to find and access commits that are unintentionally lost from performing a git reset.
git commit --amend only changes the most recent commit on your current branch. Useful for commits that:
- Haven't been pushed to the remote yet
- Have a spelling error in the commit message
- Don't contain the changes that you'd like to contain
Group 39 Cream Cat - Andy Huang, Sunho Jung, Wenxin Pan, Kevin Yee
2021 Semester 1, CompSci 732 / SoftEng 750 - University of Auckland