2f4e3db1d2647e616632eb3d88d2053811e18e8b
[feisty_meow.git] / scripts / rev_control / push_repo_downstream.sh
1 #!/bin/bash
2
3 # this script works on a specialized type of git checkout that has been configured
4 # to push to a "downstream" repository, while still pulling from its normal origin.
5 # the downstream destination might be a github or sourceforge repository that is
6 # loaded from a personal repository or server.
7 #
8 # it is assumed that you have already added your ssh key to your github account.
9 #
10 # to set up the repository for relaying downstream, just do the normal checkout
11 # or clone on it from the real origin.  for example:
12 #
13 # $ git clone git://feistymeow.org/feisty_meow feisty_relay
14 #
15 # change into that new directory:
16 #
17 # $ pushd feisty_relay
18 #
19 # and then add the downstream remote repository:
20 #
21 # # github example of add:
22 # $ git remote add downstream git@github.com:fredhamster/feisty_meow.git
23 #
24 # # sourceforge example of add:
25 # $ git remote add downstream ssh://fred_t_hamster@git.code.sf.net/p/feistymeow/trunk
26 #
27 # once the repository has been created, you can synch all updates that
28 # have been checked into the origin repository with the downstream version
29 # by running this command:
30 #
31 # push_repo_downstream ~/relay_repo_folder
32
33 #hmmm: make this support multiple dirs?
34
35 dir="$1"; shift
36 if [ -z "$dir" ]; then
37   dir=.
38 fi
39
40 pushd "$dir"
41
42 # get everything from the origin.
43 git fetch origin
44 test_or_die "running git fetch origin"
45
46 # turn off occasionally troublesome setting before checkin.
47 unset GIT_SSH
48
49 # send the little boat down the stream to the dependent repository.
50 git push downstream master
51 test_or_die "running the git push downstream"
52
53 popd
54
55