Skip to content

Instantly share code, notes, and snippets.

@lihaoml
Last active September 13, 2018 15:47
Show Gist options
  • Save lihaoml/6d8f61eb8c2f6c874a7b915185d822d5 to your computer and use it in GitHub Desktop.
Save lihaoml/6d8f61eb8c2f6c874a7b915185d822d5 to your computer and use it in GitHub Desktop.
Update several repos in one go

While regularly working with multiple repo, you may want to update them in one go.

  • Use git up instead of git pull:
git config --global alias.up '!git remote update -p; git merge --ff-only @{u}'

and here is why.

  • Create a bash script to update all repos [1]
#!/bin/sh
for repo in bean beanex banana; do
    echo "Updating git repo's in directory: ${repo}"
    (cd "$GOPATH/src/${repo}" && git checkout master && git up)
done

I put this script as go/bin/pull

  • Similarly you can push several repos in one go
#!/bin/sh
for repo in bean beanex banana; do
    echo "pushing git repo's in directory: ${repo}"
    (cd "$GOPATH/src/${repo}" && git push origin master)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment