The effect is most easily seen by looking at figure 1 again. The net effect of the git revert command is similar to reset, but its approach is different. The git cherrypick command is great when you need to pull in a bug fix from another active branch. Where the reset command moves the branch pointer back in the chain typically to undo changes, the revert command adds a new commit at the end of the chain to cancel changes. If you want to extract specific files as they were in another commit, you should see git restore1, specifically the source option. Lets say i make some changes and want to revert back to my third commit using git gui. Lets create a situation where you can revert the last commit and see how the git revert command works. You can also think of git revert as a tool for undoing committed changes, while git reset head is for undoing uncommitted changes.
If you want to add another gui tool to this list, just follow the instructions all windows mac linux android ios. Two of my favorite source code control commands for working with previous commits are git cherrypick and git revert. How to unstage individual staged file vishal monpara. Here are two ways to unstage individual staged file using git gui. How to revert changes in git tagged client config, command line, git, howto, programming, tip, tutorial. You can then commit the current tree, and it will create a brand new commit essentially equivalent to the commit you. First, before we bring the big guns in, lets make sure you really need them. When undoing in git, you are usually moving back in time, or to another. And one of the great features of the tool is that you can easily check your history and revert back if you have made a mistake. Something that i would have thought is a core feature, since its the primary reason for using source control in the first place. Once selected, click on commit menu and select unstage from commit.
Because in case you just want to edit your last commit, you can simply use git s amend feature. It allows you to correct the last commit s message as well. This requires your working tree to be clean no modifications from the head commit. If you want to throw away all uncommitted changes in your working directory, you should see git reset1, particularly the hard option. The remote repository is created on github and local on a window system. Git comes with builtin gui tools for committing and browsing, but there are several thirdparty tools for users looking for platformspecific experience. This tutorial shares how to use 4 popular commands for undoing commits and changes in git. Git is an effective tool that keeps track of your code. Both are so good programs that they allow us to do everything like commit, rollback, merge. For the demo, i have created a remote and local repository. And the ability to revert a git commit is great way to back out of a bad contribution to the code base. How to reset, revert, and return to previous states in git. How do i revert a git repository to a previous commit.
546 1419 1112 110 1023 1382 126 143 39 288 1061 1187 1232 1299 568 354 380 1469 286 612 1031 593 1054 681 160 867 35 64 626 1166 10 1058 1430 1036