Working with Git on a day-to-day basis with two different computers

10

I have two workplaces where I work in a project where I use the GIT version control. In my studies I learned some things about GIT using BitBucket.

Let's think about the following scenario:

  • My branch to deploy is the "master".
  • Whenever I'm developing I'll be in a "dev" branch.
  • Home Computer.
  • Office Computer.

I'm working from home on a first improvement and for this I first create the "dev" branch.

git branch dev
git checkout dev

Ok, I made the improvements, I made the commits in the dev branch and now I'm going to send everything to the bucket bit (remembering that I'm in the dev branch)

git push origin dev

I submitted my changes to Bit Bucket and now I have to go to the Office to work on it.

Arriving in the office I make the clone of my repository and at first it will come empty since there I will be in the master branch. Then I give the command to see all the branches

git branch -a

And I have as a result

remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/dev

Then I create a branch on the office computer based on the remote branch dev

git checkout -b dev origin/dev

I make changes to my project from the office computer, commit these improvements, and send the server to the dev branch

git push origin dev

Now I'm going home and I'm going to continue working on the project. Then I give the git pull command to download the latest changes. Except that I already have the dev branch on my home computer. So I do the following:

git ckeckout -b dev_escritorio origin/dev

Ok, now I have the version in this branch (dev_description) with the improvements I made there. I just want to continue the improvements through my dev branch so I would:

git checkout dev
git merge dev_escritorio

Well that's it, I was wondering if this is really the best way when you have to work with two different computers using git, branch, etc.

    
asked by anonymous 17.07.2014 / 00:35

2 answers

8

You have complicated yourself from this point:

  

Now I'm going home and I'm going to continue working on the project. Then I give the git pull command to download the latest changes. Except that I already have the dev branch on my home computer. So I do the following ...

Just follow the development, just by upgrading your local branch:

git ckeckout dev;
git pull;

Then make the push to origin and continue this cycle, pull -> commit - > push

Meanwhile, I recommend a more advanced flow with the use of topical branchs as you will find exemplified in chapter Branching Workflows and the use of hack and ship but this you leave more ahead in your studies:)

Image Source: git-scm.com

    
17.07.2014 / 05:25
0

I would suggest using the git flow framework. You would have the master branch that is deploy only Branch develop to get the features as it completes each new functionality So both at home and at work you would give a publish in the features to be able to work in both places in a more organized way.

I suggest to see: link

    
23.05.2018 / 01:31