By mistake i have made a commit that now i want to delete from the history log and return to a previous commit. I have been trying to checkout the commit that i want to return to but Smartgit ask me to create a local branch in order to do this (screen shot attached) and since im not an expert with SG i really need some advice. I have also try to revert the commit that i made by mistake but i still see the commit on the log. This is how the log look now:
When trying to checkout :
How my log looks at the moment :
What i want to do is delete the first two commits from the log and return to the "Cambios Varios" commit (the one with the green arrow that btw appeared when i was trying to check out that commit).
All this mess was because my coleague made some changes and add a file and then commit his changes, in order to have my files updated i made a pull but my files didn't get updated on my local repository and didnt add the file that was added by my coleague. Is there something else i have to do in order to update all my folders when another user do a commit besides PULL ? Im pretty new to SmartGit and is kinda of confusing everytime im trying to do a clean pull. Many thanks !
What you are asking is not specific to SmartGit, but to GIT in general. SmartGit is merely a client, though very convenient and fully featured. In your situation you have to take into account several GIT features:
Google on these to get additional info. Now, let's give names to your commits:
You continue to see commit
A
, because you have a branch pointing on it. This is your local branchmaster
. You can reset this branch to whatever commit you like. In SmartGit to do this, just click down on that green branch label and drag it to any other commit. That's it. E.g. reset it to commitB
, whereorigin/master
is pointing to, and you will no longer see this commit in your log, because there is no branch from which it can be reached.Strictly speaking, you may do the same trick with your
origin/master
branch, you may reset it to any other commit. But you should be very careful with it, because it points on a commitB
, which is published. I.e. anyone may have it pulled on their machine. If you cannot tell for sure, you cannot reset branch from a published commit without danger of breaking someone's copy of the repo.So the simple answer is you cannot revert the repo to the commit
C
as you want, because it may conflict with repos cloned on other machines. The longer answer is you can try it.If you are sure that the only persons that have this repo cloned is you and your colleague, you may rewrite the remote log. For this, reset your local
master
branch on commitC
(with drag&drop, as I told earlier) and push it. SmartGit may forbid you from doing so, go to Preferences/Commands/Push and enable option "Allow modifying pushed commits". Because it is dangerous.This will rewrite position of remote
master
branch, pull from it from machine of your colleague. If he did not made any additional changes to this branch, this should be fine.TLDR: Here is a screenshot of it