0

So where i work merges is frowned on and not really permitted. Team wants to use git rebase to maintain a single flow of the history and make it look linear. they dont want to see merge commits. but i came into a situation today and didn't know how to solve it. i was working on a feature branch called featureBranchA and i stashed my changes and did git pull origin develop to get changes from develop. the changes came but there was a conflict (even after the stash !!). it says the following:

CONFLICT (modify/delete): myapp/src/main/java/com/myCompany/app/rubberBands/crayons/CrayonMarker.kt deleted in 258dcbfccba83025cd0c3e1e22212e980a481a and modified in HEAD. Version HEAD of myapp/src/main/java/com/myCompany/app/rubberBands/crayons/CrayonMarker.kt left in tree.

so clearly i need to fix this conflict to move on. so i did the following commands as it looks just like some file reference needs to be updated (the CrayonMarker.kt file had been deleted but someone my git thought it was still there):

git add .
git commit -m "merging to resolve conflicts"
git stash pop

and i was back in business but my team was not happy as it 'merged' changes . they want rebase only. how could i have done this differently next time. after i fix the conflict do i just run:

git rebase develop 

what do i do after that ? commit changes ?

7
  • It depends; in your current scenario imho merge was the best option. atlassian.com/git/tutorials/merging-vs-rebasing Commented Jan 15, 2019 at 12:19
  • yah i read this. but merging is not permitted here. i want to know how it can be done with rebase then. Commented Jan 15, 2019 at 12:23
  • You should talk with them....merge is a non destructive operation.... Commented Jan 15, 2019 at 12:27
  • all they care about it keeping the history pretty. i spoke with them. Commented Jan 15, 2019 at 12:31
  • Merging is not permitted? Why? Commented Jan 15, 2019 at 12:38

1 Answer 1

1

As per the git docs:

https://git-scm.com/docs/git-rebase

Assume the following history exists and the current branch is "topic":

      A---B---C topic
     /
D---E---F---G master

From this point, the result of either of the following commands:

git rebase master
git rebase master topic

would be:

              A'--B'--C' topic
             /
D---E---F---G master

It looks like a simple rebase from your develop branch could have solved this.

Sign up to request clarification or add additional context in comments.

2 Comments

My question was after I do git rebase master do I need to commit the change and push it to master ?
Locally your branch should be branched off of the most recent develop commit. What you do from there is up to you (keep working without pushing, push to develop, push your branch and make a pull-request, etc).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.