
I've added - older commit and - newer commit to make it clear, you won’t find those notes in the editor. Note that it might be confusing at first since they are displayed in reverse order, where the older commit is on top. When you perform git rebase -i HEAD~4 will pop up an editor, showing the list of commits you want to merge. You can read the whole thing as- Merge all my ‘api-login’ branch commits on top of the commit which is 4b47ceb.

Where commit-hash 4b47ceb is added remember me checkbox. So in our example, the command would be: git rebase -interactive 4b47ceb
You can also effectively use the git checkout command: git checkoutWith the repo in this state, we are ready to initiate a git revert. At the end of the repo setup procedure, we invoke git log to display the commit history, showing a total of 3 commits. Luckily, there is another way: git rebase -interactive Here we have initialized a repo in a newly created directory named gitreverttest.We have made 3 commits to the repo in which we have added a file demofile and modified its content twice. Once the command is run, the difference between the content in the newly reset file will be cached.
git checkout master -I have tons of commits to squash, do I have to count them one by one?Ī downside of the command git rebase -i HEAD~ is that you have to guess to an exact number of commits, by counting them one by one. The following syntax will revert the selected file to be the same as the one in the master branch. more than one branch on any fork (all will have master which is the main branch).

Select those you want to revert and click on OK. Make this commits changes part of the preceding one.

#REVERT SINGLE FILE TO MASTER GIT CODE#
So, in this case, the command would be : git rebase -i HEAD~4īecause I want to combine the last four commits into one, and the commit-hash 7ccb146 added Google API Login is the fourth commit. Git maintains a history of the code base and allows you to revert to. If you want to undo all changes you made in a file since your last commit you need to select the file, right click to pop up the context menu and then select the command TortoiseGit Revert A dialog will pop up showing you the files that youve changed and can revert. So, In our case, we will write the value of is 4, because we want to join these four commits into one commit.
