How do I execute several git commands in a batch file without terminating after the first command?

后端 未结 3 835
刺人心
刺人心 2020-12-24 04:24

I tried to put a series of GIT commands that I always use continuously togeter as batch files so that I don\'t repeat myself too much. For example, I have this batch file ca

3条回答
  •  感动是毒
    2020-12-24 05:29

    As i see from your example you're actually trying to sync your local branch 'branchname' with origin/branchname

    For this you don't need any additional scripting, you just have to use git pull instead of sequence git checkout branchname; git fetch origin; git merge origin/branchname

    take a look at the docs about tracking branches in git and their benefits.

    generally speaking if you have a repo layout like this:

    git branch -a
    ...
    master
    dev1
    dev2
    remotes/origin/master
    remotes/origin/dev1
    remotes/origin/dev2
    

    And your dev1 and dev2 branches are tracking branches for origin/dev1 and origin/dev2 correspondingly then you just need to execute in repository:

    git pull
    

    This command will effectively sync up all you local tracking branches with remote ones.

    for more see here:

    Git pull docs

    Git remote branches and tracking branches (Progit book)

提交回复
热议问题