![]() Using git revert is a safe way to undo a specific change, preventing any of the typical complications that occur when altering the commit history of a project.Įarlier, we discussed git commit and identified that commit messages are an important aspect of crafting a detailed project history. Note, you can’t use git revert to resolve conflicts-if there are more recent conflicting changes, Git will ask you to resolve as if it’s a merge conflict. Git revert can be used on commits at any point in the repository’s history without affecting other work. You could use git revert to change all of your headings back to Heading 3 instead of going back through every Heading 5 and changing them back to Heading 3s. Git revert creates a new commit with changes that are the opposite of the commit that is functionally being 'undone'.įor example, imagine within the commit history of a repository, there was a commit that changed all of your Heading 3s to Heading 5s. As a general rule, you should only use git revert if the commit has been pushed to the remote. Since these commit IDs are immutable, you could potentially cause issues for other collaborators. But beware, some commands that help us fix mistakes destructively modify the commit ID. Thankfully, Git comes equipped with commands that allow us to fix our mistakes. Sometimes we make small mistakes (or big ones!). It includes things like commit author, time and date of the commit, and a list of the changes that were made to the various assets within the repository. For example, to compare two commits with SHA-1 hash references 4e3dc9b and 0cd75d4, enter command: git diff 4e3dc9b 0cd75d4įinally, if you would like to view the changes that were made in a previous commit, you can use the git show command to display the details of that specific commit. You can also use git diff to compare between any two commits, branches, or tags in the repository.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |