0

I am working on project where 5-6 members also work.Usually start of the sprint every body create a local branch in his/her machine and start with his/her story.

Every day There will be push to master and finally story gets merged after review.

Currently I am re basing my changes only after competing my story.

so I am doing following

git add .       
git commit 
go checkout master.   
get pull   
get checkout localbranch
get rebase

This process of rebasing at the end results in lot of conflict at once. I wanted to be updated with master daily.Please suggest me how to do that.

Vikram Ranabhatt
  • 7,268
  • 15
  • 70
  • 133
  • 1
    It sounds very much like you don't really need your local master branch. Without moving from your `localbranch` you could replace the last four commands with `git fetch && git rebase origin/master`... there was another question about this... searching. – CB Bailey Apr 03 '14 at 13:47
  • possible duplicate of [Update \*\*not\*\* the current branch (in Git)](http://stackoverflow.com/questions/13580484/update-not-the-current-branch-in-git) – CB Bailey Apr 03 '14 at 13:51
  • If there are conflicts to resolve, though, there are conflicts to resolve. There's no real magic that'll get rid of them. – CB Bailey Apr 03 '14 at 13:56
  • @CharlesBailey is this really a duplicate? The question was more about avoiding conflicts than finding an easier way to update `master` in a daily workflow. –  Apr 03 '14 at 21:07
  • @Chris_vr see also [git: update a local branch without checking it out?](http://stackoverflow.com/questions/3216360/git-update-a-local-branch-without-checking-it-out/17722977#17722977). –  Apr 03 '14 at 21:08

1 Answers1

0

@CharlesBailey is right about conflicts: if you're going to get conflicts, there's nothing you can do about that other than to just resolve them.

However, you can decrease the changes that you'll have conflicts, or have really complicated and difficult to resolve conflicts, by syncing your work with upstream work frequently. Syncing code daily might be too infrequent for you. At my last job, I frequently synced code multiple times within an hour.

It's easy to do if you use an alias that updates the master branch for you without checking it out. You can make an alias like this one:

[alias]
    sync = !sh -c 'git checkout --quiet HEAD && \
        git fetch upstream master:master && \
        git checkout --quiet -'

See also git: update a local branch without checking it out?.

Community
  • 1
  • 1