i just tried to reset some wrong commits (struggling wit sourcetree) to a previous state. i read some question about it here so i tried (from here):
"Reset current branch to this commit"
"log selected" on file -> "Reset to commit"
The problem in both cases was that this only reset local repository and as soon as i did i see a red number on pull - so i can't commit that reset til i pull, but if i pull the reset is undone. i walked this circle a couple of times (and tried some other stuff):
At the and i fooled source tree by copying my desired version and overwrote the file after pull :-P. So how to reset to a previous commit and push that reset to remote/origin? i don't want to merge i just want to discard all changes local and remote.
thx in advance
The problem in both cases was that this only reset local repository and as soon as i did i see a red number on pull - so i can't commit that reset til i pull
So what's happened here is that, for example, you've reset three commits locally. A git fetch would get the three commits that you had previously pulled and then reset from, so the pull count would show a number '3' on it immediately because SourceTree auto-fetches commits in the background.
The second part of your statement doesn't make sense though. Even though there's commits to pull, you're still free to commit uncommitted changes before you pull, it's just you can't push these changes until you pull and merge. So pulling shouldn't be a problem provided you commit though changes.
In your case you want to do a 'Reverse Commit' which is also available from the context menu of a commit from the log view. This will yield one of two states. Either a merge conflict which you need to resolve because it's applying the changes in reverse on top of your HEAD commit, or it will cleanly apply the reversed changes and auto-commit for you and the HEAD commit will be 'Revert <msg>'.
Hope that helps
probably i have to say i am new to git, but thx to sourcetree i gave git a chance :-).
"can't push these changes until you pull and merge"
The problem is i don't want to merge (or is there a way to say - throw away all remote changes? - like "mark as megred"). I want to make my current local state the tip of remote - undoing all changes/differences. Is this possible? Or how to make it with git/ source tree. in svn i can "revert to this revision" on remote - an local update (pull) will yiled the old state.
(see accepted answer) i think i want "git reset --hard HEAD~n" is this possible with source tree?
You don't have to merge, you can just the "rebase" option from the pull sheet to stop it from creating a merge commit.
Yup, a Git reset is possible, just context-click on the commit in question and choose "Reset <branch> to this commit..." then from there you can choose the 'hard' option from the drop-down.
If you haven't pushed those commits yet then this shouldn't be a problem. If you have pushed the commits you want to undo then you should really revert those commits and re-commit the amended changes to keep the project history. Generally you should go on the rule that if it's on the remote, then it stays on the remote just because it could cause problems for collaborators in a bad way.
Thx, let me just summ up the steps needed - probably you have to correct them:
1. right click the commit i want as new tip/state of remote and local branch
2. click "reset to this commit" - choose "hard"
3. no i see the red number on "pull" signaling the difference to remote - click "rebase" to say "mine is the new truth"
In my special case there are no collaborators so a real roll back would be also an option - could this be achieved with sourcetree?
Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG