So I accidentally made changes with the master branch, when I was supposed to do it with my own branch.
Somehow I ended up like this:
Inside the red area: the ones that I want to delete.
Inside the blue area: the ones that I want to keep.
As you may or may not notice, I'm really new to these kind of things. I already deleted the master branch. What should I do to accomplish this?
when you say you deleted master branch, did you delete from your local and is it still there in remote? if you did not push the changes to master, then you are all good , your changes to master is already gone, now you can pull a fresh copy of master branch from server. in this case the changes you did are gone with the deletion.
if you did not delete the local copy of master, and have not pushed your master branch to remote yet ,you could merge the master branch to local branch to move all the commits from master to fabian branch and then do a git "reset" of master branch to that commit . reset will move the pointer back to the commit id you select. alternatively you may git revert the commits in master branch, which will create new commits in master branch to revert the changes in master branch.
hope this helps.
It looks like you pushed your changes to master to the "origin" remote. This is a problem for you - it is dangerous to try to rewrite history that has been pushed to other repositories.
The safest approach is to make an additional commit to master that reverses the changes that aren't supposed to be there. SourceTree can help you with this if you right-click on each bad commit, and choose "Reverse commit".
To fix your Fabian branch - DO NOT PUSH IT. From your screenshot, the change you don't want has not been pushed. This makes it safer to rewrite the history to remove that commit. First, checkout your local Fabian branch. Second, right click on the commit that you want your Fabian branch to be on (probably origin/Fabian). Select "Reset current branch to this commit". In the dialog that comes up, a hard reset will also overwrite your working copy. A mixed reset will keep the changes from the bad commit as Uncommitted changes.
Hope that helps.
A few words on: "It looks like you pushed your changes to master to the "origin" remote. This is a problem for you - it is dangerous to try to rewrite history that has been pushed to other repositories." This is very true if your repository is a collaborative repository (if other developers use the remote repository as well). In this case it's common agreement not to rewrite the history for remote repositories - whilst other developers still have cloned the original remote repository. ***Rewriting the history of the remote repository might solve YOUR problems, but causes trouble to all other users of the remote repository.*** As long you are the single user of the remote repository, it's your free decision to rewrite the history of the remote repository. (This is also valid, if you are a small group of developers. You have to communicate clearly, that you're gonna rewrite the history. Each developer has to finish his work then and push the changes BEFORE you start rewriting the history. During rewriting your fellow developers must not work on the repository. After rewriting each of your fellow developers has to remove their old local repository and clone the (modified) repository again. Rewriting actions depend of your goals: * if you want to get rid of the commits within the red box, do a "git reset --hard" * if you want to keep the changes, but want to have it on your own branch "Fabian": simply exchange the branches Fabian and master (first delete the branches an create them at the desired commits again). In both cases you do have to do a "git push --force" to push your modifications to the remote repository
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
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs