Question

History:

  • Remote had 8 branches and I forked to create my origin.
  • I created my branch and started working on it.
  • I switched to origin master branch and pulled the remote master branch.

Situation:

  • Remote has 1 new branch while all old(8) branches are merged to master.
  • My local has 8(mainline)+1(mainline master)+1(origin master)+1(origin my new branch)+1(mainline new branch) =12 branches.

Question : how do I sync local and remote?

Was it helpful?

Solution

If you have the original remote named remote and your remote named origin, try:

git remote update
git remote prune origin
git remote prune remote

You could then find your local branches which are merged in

git branch --merged remote/master

and delete them:

git branch -d <branch>

You could delete all branches merged into the current HEAD with one command:

git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d

Now you should have everything cleared up and you should have a lot less branches.

The actual synchronisation you could achieve with:

git checkout master && git pull --rebase remote master

(If your local branch you want updated is named master).

You could omit the --rebase flag if there are a lot of conflicts with the updated remote branch.

OTHER TIPS

Are you having conflict issues? To have your master-local / master-remote "sync" up, you must manually handle all conflicts.

This is discussed here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top