Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating all repos in a folder?

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.

like image 582
cannyboy Avatar asked Mar 28 '13 23:03

cannyboy


People also ask

Can I have multiple git repositories in one folder?

Combining two git repositories. Use case: You have repository A with remote location rA, and repository B (which may or may not have remote location rB). You want to do one of two things: preserve all commits of both repositories, but replace everything from A with the contents of B, and use rA as your remote location.

How do I update a specific directory in git?

you can use git fetch to update the objects in your local clone, and then you can git checkout those particular files. This will update the file in your working directory and add it to the index ready to be committed on your local branch.


3 Answers

Try this:

cd repos
find . -maxdepth 1 -type d -exec sh -c '(cd {} && git pull)' ';'
like image 189
Ruslan Osipov Avatar answered Sep 20 '22 12:09

Ruslan Osipov


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.

like image 36
Melvin Columna Avatar answered Sep 18 '22 12:09

Melvin Columna


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
)
like image 24
Shital Shah Avatar answered Sep 20 '22 12:09

Shital Shah