Git: workflow for two dev working on one branch

When you first came to Git, it was such a SOB. One mistake and you’re screwed. But the more you get to know Git, the more you’ll fall in love with it. And I’m obliged to transfer that affection to you ^ ^.

Say, young Anakin and Caption Kirk set out for a new project, codename “Star War Trek”, whose end result would bring balance to the force and peace to the Federation. The Jedi council has decided that in order to achieve their ultimate goal, the first step is to reveal the true identity of Sith. They, therefore, have assigned our two young heroes to this challenging mission: sith_reveal. May the force be with them.

Apparently both Anakin and Kirk don’t want their mission’s outcome to affect the project. Anakin initializes their mission by typing into his command center:

“git checkout -b sith_reveal master”

which tells it to create mission with up-to-date information from the Jedi Council. He then publishes the newly-created mission data to the Council computer, so that Master Joda will know what’s going on along their journey.

“git push” or the more specific command “git push origin sith_reveal”

Young Anakin then turns to Kirk:”Hey caption, I’ve created our mission data, go grab it!”

“git pull” | Pull data from the remote repository
“git checkout sith_reveal” | Switch to the newly-created branch

“Ok, so I got the mission data to my own command center. Now should we both work on it or split?”, Kirk wonders. He then turns to Anakin, saying in a decisive manner:”Each of us should work on smaller parts of this mission. It’s too dangerous to put everything in one basket! It’s the Dark Lord, remember?”

“git checkout -b sith_reveal_anakin sith_reveal” | create a new branch out of “sith_reveal”

Anakin quickly types the command. He can’t agree more with his caption.

“git checkout -b sith_reveal_kirk sith_reveal”

Kirk follows suit. And there we go, the two heroes have officially embarked upon their mission to save the universe. Woot!!!

At some point each of them feels the urge to let the other one know what they’ve been through. Anakin, as a subordinate, initiates the process.

“git rebase sith_reveal” |update sith_reveal_anakin with latest patches from sith_reveal
“git checkout sith_reveal” |switch back to sith_reveal
“git merge sith_reveal_anakin” |merge sith_reveal_anakin into sith_reveal
“git push”|push everything to the repository

Then Kirk updates his main mission data.

“git checkout sith_reveal”
“git pull origin sith_reveal” |update sith_reveal

Now that Kirk has had the latest data, he also wants to update Anakin on the news.

“git checkout sith_reveal_kirk” |switch back to sith_reveal_kirk
“git rebase sith_reveal” |update sith_reveal_kirk with latest patches from sith_reveal
“git checkout sith_reveal”
"git merge sith_reveal_kirk" | merge sith_reveal_kirk into sith_reveal
“git push origin sith_reveal” |push the merges to the repository

Anikin will then pull the data. And continues his mission. From time to time they will redo the above process.

However, the Jedi Council have also made some moves in the process. And our two men definitely want to know what’s up with Master Yoda.

Anakin does the job, pretty well I think.

“git checkout master” |check out to local version of the master branch (out-of-date)
“git pull”
“git checkout sith_reveal”
“git rebase master”

Finally, the chosen ones have lived up to expectations. They managed to reveal the true identity of the Sith.

Anakin will therefore merge their mission into the Council overall performance. He has to update
his data first, of course, by reapplying the previous process.

“git checkout master”
“git pull”
“git checkout sith_reveal”
“git rebase master”


“git checkout master”
“git merge sith_reveal”
“git push”

So it looks like a successful mission. We’re all delighted. But it is such a critical mission that Master Yoda had to prepare for our young men with some fail safe measures. He didn’t think the mission would fail. But prepare well, they must! Yoda began:

  • Always keep your data up-to-date before doing anything. “git pull” should be done before anything else. And commit any changes before its too late.
  • “git gui” is your friend. I know you both come from the world of wizardry where Graphical User Interface is a joke. But give the git gui as try when disaster strike.
  • If anything fails, go with “git reflog”. It’s the magic of all magic. The Jedi way of the mind. You may want to google it for further information.
  • Always rebase before merging smaller missions.
  • Should conflicts emerge, you should peacefully resolve them by “git mergetool”. Even though I don’t expect conflicts to happy among Jedi knights, it’s just the way life is.
  • And with his teachings, Kirk and Anakin have emerged victorious.

    P/S: Lolz. Hope you guys have fun. This is basically what we’re doing for our project. We’re by no means close to understanding the way Git works, so should you know of any better way to work with it, please let me know. Lesson is you should always read the manual first. But turns out if you can make it without the manual, you can write one. LMAO

This entry was posted in Web development and tagged , , , , , , , , , , . Bookmark the permalink.

One Response to Git: workflow for two dev working on one branch

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>