1

In my current project all the team members are new to Git where recently we got some collaboration scenarios during development.

My question is if multiple team members works on a project where each developers (in this scenario Developer 1 & 2) has created their local feature branches in local.
However there is a dependency on each others module.
To get the latest code of Developer 1 code to Developer 2 machine is the approach would be to push the feature branch of Developer 1 to GitHub remote so Developer 2 can fetch the latest code of Developer 1 and after the changes push the Developer 2 branch to master for merge?

Please let me know if there is any best practice around this.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Sujit
  • 468
  • 1
  • 8
  • 22

1 Answers1

0

Hopefully, we are not talking about a crossed dependency here (where dev1 depends on dev2 code who depends on Dev1 code)

For a simple dependency, Dev2 would need to do (after Dev1 updates his/her feature branch)

git fetch
git checkout dev2_feature_branch
git rebase origin/dev1_feature_branch
git push -f

(or git push -u origin dev2_feature_branch if this is the first time that branch is published)
That process can be repeated as many time as needed.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • That's correct. There is no circular dependency and your approach make sense for Dev2 can fetch from dev1_feature_branch and after modification push the same. Thank you. While Dev2 do a fetch then there may be a possibility of conflict then in that case Dev2 need to resolve and push updated changes. Correct me if i am wrong. – Sujit Aug 07 '17 at 06:52
  • @SujitTripathy The fetch it self does not trigger any conflict: it just update the remote history in your local repo. The rebase is where conflicts may arise, when replaying your commits on top of the ipdated remote dev1 branch. If you find yourself repeating that rebase multiple times (and resolving the same commits), have a look in `git rerere`: https://stackoverflow.com/a/44471764/6309 – VonC Aug 07 '17 at 06:56