viplooki.blogg.se

Sourcetree discard all
Sourcetree discard all









sourcetree discard all

Since the working directory contains the state of commit B and the index is resetted to A a git status will show you the changes that commit C contains but are not committed yet. That gives us the opportunity to create a new commit that only contains the changes we want to revert on top of commit C. Will show you all changes introduced in commit B as unstaged changes. Now the index’s state is the state of the previous commit, but the working directory still contains the files of commit B. Checkout the commit that contains the changes you want to revert in detached HEAD state.

sourcetree discard all

Since the commits B and C are already pushed we should not rewrite them, but we don’t need to rewrite them as I will show you now.

Sourcetree discard all how to#

So the question is how to isolate changes into an own commit or split a commit in multiple commits? Now if you want to revert the changes to file2 and file4 of commit B but not the other changes you can’t simply do a git revert B. But if you can isolate the changes into a single commit you can use git revert. Commit C is based on commit B and is already pushed to the remote repository, because origin/master and master refer to the same commit.

sourcetree discard all

Commit B contains changes to the files file1, file2, file3, file4. In the next sections I will show you how to do it.Īs you can see the git repository contains 3 commits with the ids A, B, C. So what should you do if you only want to revert a part of a big commit in a safe manner? Fortunately git provides tools you need to do this. In other words… if commits are fine-grained it is very likely that the changes you want to revert are only contained in one commit. This works well if commits have a high cohesion in matters of the tasks they implement. So all changes contained in this commit will be reverted. This git command reverts the whole commit. Normally you revert a commit using git revert.











Sourcetree discard all