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
I would suggest to manage the update of all the repos with a cron script.
Here is an example script for auto update base to their upstream.
#!/bin/bash
repo_update() {
echo -e "\nUpdating $1" && cd $1
if [[ `git rev-parse --abbrev-ref HEAD` != master ]]; then git checkout master; fi
GIT_URL=$(git config --get remote.origin.url) && REMOTE=${GIT_URL##*:}
REMOTE=https://api.github.com/repos/${REMOTE%.*}
UPSTREAM=$(curl -s $REMOTE | jq -r '.parent.ssh_url')
if [[ $UPSTREAM == null ]]; then return 1; fi
if grep -q $UPSTREAM << EOF
`git remote -v`
EOF
then
git remote set-url upstream $UPSTREAM
else
git remote add upstream $UPSTREAM
fi
git fetch --prune upstream
if [[ `git rev-list HEAD...upstream/master --count` == 0 ]]
then
echo -e "all the same, do nothing"
else
echo -e "update exist, let's checking!"
git pull --rebase upstream master
git reset --hard upstream/master
push $GIT_URL
fi
}
# Check connection
ssh-add -l &>/dev/null
if [[ "$?" == 2 ]]; then eval `ssh-agent` > /dev/null; fi
# Check identity
ssh-add -l &>/dev/null
if [[ "$?" == 1 ]]; then expect $HOME/.ssh/agent > /dev/null && ssh-add -l; fi
# Update repositories
find ~/.gits -maxdepth 1 -mindepth 1 -type d | while read repo; do repo_update $repo; done