Reputation: 2052
Although my question looks similar to this one, instead of GitHub I use pendrive and I also have two backups. Well, let me describe it below.
I use Kepler with EGit and command line git and have local repo "L1" (with working set) and also remote bare repo "R1" on another disk partition on the same computer "C1". L1 is configured to push/pull to/from R1. Besides I made a bare clone "P" of R1 on a pendrive "PD" so P is configured to fetch from R1. On another computer "C2" I made a clone "R2" of P so R2 is configured to fetch/push form/to P and then checkout out project form R2 into Eclipse using repo "L2" (with working set), so L2 is configured to fetch/push form/to R2. It basically server to exchange changes between two computers with help of pendrive and having bare backups on both computers. It looks like this:
C1: {L1, R1}; PD: {P}; C2: {R2, L2};
It is configured like this:
L1 <--pull push--> R1 <--push fetch--> P <--push fetch--> R2 <--push pull--> L2
After sequence commit(L1).push(R1)
, P.fetch(R1)
, R2.fetch(P)
git says R2 and P are up-to-date, however I made commit to L1 and definitely they should differ. Any thoughts what do I do wrong and how to make it actually work?
Upvotes: 1
Views: 119
Reputation: 2052
Finally I was able to synchronize all the repositories, but I had to get rid of fetch
and use only push
command.
As to details:
Now as to P configuration: as I said, it looks like A.push(B)
works a bit different
than B.fetch(A)
(both repos are bare). So when I push something to P (from R1 or from R2)
and want to synchronize with other remote (like R2 or R1), I perform push from P, but I simply
change remote URL just before push. For this purpose I prepared a bash script (push-all.sh
)
that looks like this:
#!/bin/bash
url=`cat $1.url`;
for f in *.git
do
cd $f;
echo "Setting URL to $url$f";
git remote set-url origin $url$f;
git push;
cd ..;
done;
Note that all my bare repositories have *.git at the end of directory name.
On this pendrive there are two files (could be more if needed) contaning paths to repos on remote machines with extention *.url (could be anything actually):
$ cat c1.url
d:\my\path\on\c1\git\
$ cat c2.url
e:\another\path\on\c2\
On C1 and C2 under git urls I have another push-all.sh
script, but a little simplier:
#!/bin/bash
for f in *.git
do
cd $f;
git push;
cd ..;
done;
So now, when I finish work on C1 I make sure pendrive is connected to the computer and it has the same letter as in R1 configuration and I do:
$ cd /d/my/path/on/c1/git
$ ./push-all.sh
Now all my work is copied from R1 to P. Then, when I get to computer R2 I do:
$ cd /p/git-repo-on-pendrive
$ ./push-all c2
Then I pull from EGit and there are all my changes. When I finish work on C2 I do:
$ cd /e/another/path/on/c2
$ ./push-all
And when I get to C1 I do:
$ cd /q/git-repo-on-pendrive
$ ./push-all c1
and I do pull from EGit. All this solved my case.
Upvotes: 0
Reputation: 76997
You need to do a R1.push(P)
or P.pull(R1)
.
There is no difference between R1.push(P)
and P.pull(R1)
, except that in the former, push
has to be run in R1
and hence P
must be a remote in R1
, while in the latter, pull
has to be run from P
and hence R1
must be a remote in P
.
P
is currently not updated completely, you only fetched the changes, didn't merge them.
As for the LAN/limited network issues, you can try using bitbucket for private repository, github for public repos. Either should be available at both locations.
EDIT
I just realised that my typo costed OP a lot of debugging effort - I meant P.pull(R1)
earlier and not P.fetch(R1)
as stated. Really sorry for that. A pull
can be thought of as fetch
+merge
in a single operation. In fact, that was the first line of my answer, use a push
or pull
- I had meant to ask you to use a pull
and not do a fetch
. Once again, really sorry for the miscommunication.
Upvotes: 1