Make a shell script to update 3 git repos

前端 未结 4 1922
心在旅途
心在旅途 2021-01-31 04:09

I am working with 5 repos that I have cloned in my development environment. When I want to update a git repo, I enter the folder /home/adrian/repo1/ and do:

git checkout

4条回答
  •  后悔当初
    2021-01-31 04:31

    First, I recommend against using git pull. Instead, create a safer git up alias:

    git config --global alias.up '!git remote update -p; git merge --ff-only @{u}'
    

    See this answer for an explanation of git up.

    Then you can safely script it:

    #!/bin/sh
    for repo in repo1 repo2 repo3 repo4; do
        (cd "${repo}" && git checkout master && git up)
    done
    

提交回复
热议问题