I have messed up my git repository a bit. I have worked on several branches at one and made merges which in retroperspective were a really bad decision.
I was working on branches JIRADAPTER-108, JIRADAPTER-109 and JIRADAPTER-104 (see attached picture of the history). JIRADAPTER-108 and JIRADAPTER-109 were bugfixes which i branched from master and merged back to master with only one commit respectively. To use those changes I decided to merge the master into branch JIRADAPTER-104, which turned out to be a bad idea!
At first glance i was not able to merge back everything from branch JIRADPATER-104 into master, as foxtrot merges are not allowed. This was, as I tried to merge from origin/JIRADPATER-104 (last green commit).
I was able to merge the right changes into master by merging from the last commit before merging the master into JIRADAPTER-104 (last pink commit).
Jan 31, 2019 git branch -merged master lists branches merged into master. Git branch -merged lists branches merged into HEAD (i.e. Tip of current branch). Git branch -no-merged lists branches that have not been merged. By default this applies to only the local branches. The -a flag will show both local and remote branches, and the -r flag shows only the remote branches.
Although only cosmetic, i now, try to get rid of those to commits to branch JIRADAPTER-104, where i merged the master into it (all green commits).
I was trying to reset to the last pink commit: without success.
Can anybody help me to get rid of those two green commits, so that origin/JIRADAPTER-104 and JIRADAPTER-104 tags are on the last pink commit?
EDITUsing worktree, be sure to have set the option
Enable Force Push
under Tool > Options > Git
.Then the workflow is quite similar as Mlad274 suggested (many thanks for that):
- Click on the commit which should be last in a branch
- From the context menue select
Reset current branch to this commit
- Push (select
Force Push
at bottom of the menu`)
Simon Fink
Simon FinkSimon Fink
1 Answer
![Git Git](/uploads/1/2/4/8/124895079/182071767.png)
Since you know the commit you want, just force the branch to point to it.
git checkout JIRADAPTER-104
git reset --hard <COMMIT-ID>
git push -f
Vlad274Vlad274
Not the answer you're looking for? Browse other questions tagged gitatlassian-sourcetree or ask your own question.
I have two branches with the following files in there:
branch a:
branch b:
I want to merge them, so that I get both files from a and b (and files that exist in both should normally be merged)! is that possbile?
reoxreox
1 Answer
this might help: http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging
in your case you would do the following:
git checkout a
(you will switch to branch a)git merge b
(this will merge all changes from branch b into branch a)git commit -a
(this will commit your changes)
take a look at above link to get the full picture.
udoudo