chriskvik
chriskvik

Reputation: 1281

GitHub working on separate branches but same class. How would we merge this?

We are currently 2 people working on a project. We use github, we have one master branch. And 2 sub branches for each developer. So in total we have 3 branches with master.

Lets say we have a file hello.class. Both developer makes changes to the file in their respective branches. If I now push and merge my sub-branch with master. The other sub-branch falls behind and needs to pull master, and then rebase it with hes sub-branch.

The problem now occours, because if he rebase's masters changes, he overwrites he's work in hello.class. How would we go about solving this problem? Is there a way to pull master, and then automerge changes into the sub-branch without overwriting the work done in the file?

Upvotes: 0

Views: 904

Answers (2)

Eevee
Eevee

Reputation: 48536

Merging is half of what git is for. If the changes conflict, git will abort the merge/rebase and ask you to fix them up before continuing; if the changes are in different parts of the file, git will do the merge itself. You have to go out of your way to lose work.

Upvotes: 3

Jason
Jason

Reputation: 13956

Git doesn't overwrite changes. It merges them when you do a rebase (you could also do a merge, i.e. git merge master). If you both change the same line of code then git will get confused and ask you to fix merge conflicts. But if you didn't change the exact same line, git is smart enough to merge the changes.

I'm assuming that you are committing .java files as you shouldn't be committing .class files.

Upvotes: 1

Related Questions