]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - bin/git-update.sh
bin/updated-git.sh: Add. Syncs git repository with all remotes.
[config/dotfiles.git] / bin / git-update.sh
1 #!/bin/sh
2
3 # Push current commits to all remotes and fetch from all remotes. Then display
4 # unmerged commits and changes in the repositories.
5 #
6 # If an argument is given cd to this directory before running the commands.
7 #
8 # Very useful to sync multiple remotes.
9
10
11 if [ x$1 != x ]; then
12     echo $1
13     cd "$1"
14 fi
15
16 # Get all remote changes.
17 git remote update 2>&1 | grep -v Fetching
18 # Push all local changes to remote(s).
19 for remote in `git remote`; do
20     git push $remote 2>&1 | grep -v 'Everything up-to-date'
21 done
22 # Show unmerged changes.
23 git branch -rv --color --no-merged
24 # Show uncommitted changes.
25 if `echo "$1" | grep '\.git\$' > /dev/null`; then
26     cd ..
27 fi
28 git status | grep 'Changes to be committed:' > /dev/null \
29     && echo '-> modified (staged)'
30 git status | grep 'Changed but not updated:' > /dev/null \
31     && echo '-> modified'
32 git status | grep 'Untracked files:' > /dev/null \
33     && echo '-> modified (untracked)'
34
35 echo