Updating all repos in a folder?

2019-02-03 17:55发布

I've got a folder - 'Repos' - which contains the repos that I'm interested in. These have been cloned from bitbucket, but I guess github could be a source too.

Repos
    - music-app
    - elephant-site
    - node-demo

Is there a git command that I can use which steps thru every folder in Repos and sees if there are new commits on the server, and the download the new stuff? And if there are new commits locally, then upload these.

6条回答
不美不萌又怎样
2楼-- · 2019-02-03 18:20

Try this:

cd repos
find . -maxdepth 1 -type d -exec sh -c '(cd {} && git pull)' ';'
查看更多
闹够了就滚
3楼-- · 2019-02-03 18:20

To maintain several repos, you can use git submodule.

Use git submodule add to add a repo as a submodule and use git submodule foreach git pull to update the repos.

This method is like you have a super project, with several git projects in it.

查看更多
smile是对你的礼貌
4楼-- · 2019-02-03 18:23

For Windows, this should do it for you via a Command Prompt:

cd c:\repos
for /d %a in (*.*) do cd c:\repos\%a && git pull

Once you go back to the GitHub client, you should see the updates.

查看更多
疯言疯语
5楼-- · 2019-02-03 18:34

For Windows, I'm using below in .cmd file. It can easily be extended to do something more or something else:

for /d %%i in (*) do (
  pushd "%%i"
  git pull
  popd
)
查看更多
相关推荐>>
6楼-- · 2019-02-03 18:37

What I have is a scriptlet that does something like:

for d in *
cd $d
git pull
cd ..

(Yes, it has a few extra bells and whistles, in that I have a few hg repos, and others I manage in git from SVN upstream.)

查看更多
老娘就宠你
7楼-- · 2019-02-03 18:47

gitfox is a tool to execute command on all subrepo

npm install gitfox -g

g pull

查看更多
登录 后发表回答