This usage of git reset is a simple way to undo changes that haven’t been shared with anyone else. In other words, you’re saying that you want to throw away these commits. The two commits that were on the end of hotfix are now dangling commits, which means they will be deleted the next time Git performs a garbage collection. For example, the following command moves the hotfix branch backwards by two commits. This can be used to remove commits from the current branch. On the commit-level, resetting is a way to move the tip of a branch to a different commit. Note that git revert has no file-level counterpart. That’s what we’ll be exploring in this section. When you don’t include a file path as a parameter, they operate on whole commits. The parameters that you pass to git reset and git checkout determine their scope. Keep these components in mind as you read through this article. It helps to think about each command in terms of their effect on the three main components of a Git repository: the working directory, the staged snapshot, and the commit history. Hopefully, you’ll walk away with the confidence to navigate your repository using any of these commands. In this article, we’ll compare the most common configurations of git reset, git checkout, and git revert. They all let you undo some kind of change in your repository, and the first two commands can be used to manipulate either commits or individual files.īecause they’re so similar, it’s very easy to mix up which command should be used in any given development scenario. The git reset, git checkout, and git revert command are some of the most useful tools in your Git toolbox.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |