Can “git pull --all” update all my local branches?

前端 未结 25 2494
失恋的感觉
失恋的感觉 2020-11-22 16:33

I often have at least 3 remote branches: master, staging and production. I have 3 local branches that track those remote branches.

Updating all my local branches is

25条回答
  •  猫巷女王i
    2020-11-22 17:35

    I use the sync subcommand of hub to automate this. I have alias git=hub in my .bash_profile, so the command I type is:

    git sync
    

    This updates all local branches that have a matching upstream branch. From the man page:

    • If the local branch is outdated, fast-forward it;
    • If the local branch contains unpushed work, warn about it;
    • If the branch seems merged and its upstream branch was deleted, delete it.

    It also handles stashing/unstashing uncommitted changes on the current branch.

    I used to use a similar tool called git-up, but it's no longer maintained, and git sync does almost exactly the same thing.

提交回复
热议问题