![]() ![]() * _Child commits will techincally become new commits_ * Adding a file to a commit turns it into a _new_ commit * A reworded commit is technically a _new_ commit * A commit's hash depends on the files' data, the commit message, commit info, _and the parent_ * `rebase` and `commit -amend` _rewrite_ commits if you make changes * Playing back commits on top of another branch (more on this later) * This allows you to put multiple minor commits into a single more substantial one * `` is either a commit hash or branch that you want to replay commits _onto_ * `git rebase -i ` is the form you most likely will use * `git rebase` is an incredible powerful command that allows you to rewrite history * `git commit -amend` with no staged files will just have you edit the commit message * `git commit -amend -no-edit` won't ask you to edit the commit message * If you forgot to _delete_ a file, just `git rm ` to remove and stage the removal, the `git commit -amend` * `git commit -amend` will bring the currently staged changes into the current commit and allow you to edit the commit message * `-hard`: undoes the commit and brings the Working Directory to the state of the commit, discarding the changes * `-mixed`: default, undoes the commit, leaves the Working Directory untouched, and leaves the changed files _unstaged_ * `-soft`: undoes the commit, leaves the Working Directory untouched, and leaves the changed files _staged_ * `git reset` has three major modes in this application: * We could provide the commit's hash or some reference/pointer to a commit instead (e.g. * `HEAD~1` specifies that we want the HEAD to take on the state of the commit that is 1 before the HEAD * `git reset` sets the HEAD to a specified state (bringing the current branch along for the ride) * `git reset HEAD~1` is a common internet answer given without explanation # Scenario: made a commit by accident and want to "uncommit" ![]() * _If you force the remote branch to take on the rewritten history, it'll cause the other peoples' local branches to be incoherent_ * _Use with caution if you have already pushed them to a branch that's shared with other people_ * _This section involves changing up commit history_ # "Boy I sure do love creating a merge commit every time I pull!" ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |