version control - git repository sync between computers, when moving around? -


let's have desktop pc , laptop, , work on desktop , work on laptop.

what easiest way move git repository , forth?

i want git repositories identical, can continue left of @ other computer.

i make sure have same branches , tags on both of computers.

thanks johan

note: know how subversion, i'm curious on how work git. if easier, can use third pc classical server 2 pc:s can sync against.

note: both computers running linux.


update:

so let's try xani:s idea bare git repo on server, , push command syntax kingcrunch. in example there 2 clients , 1 server.

so let's create server part first.

ssh user@server mkdir -p ~/git_test/workspace cd ~/git_test/workspace git --bare init 

so 1 of other computers try copy of repo clone:

git clone user@server:~/git_test/workspace/ initialized empty git repository in /home/user/git_test/repo1/workspace/.git/ warning: appear have cloned empty repository. 

then go repo , add file:

cd workspace/ echo "test1" > testfile1.txt git add testfile1.txt git commit testfile1.txt -m "added file testfile1.txt" git push origin master 

now server updated testfile1.txt.

anyway, let's see if can file other computer.

mkdir -p ~/git_test/repo2 cd ~/git_test/repo2 git clone user@server:~/git_test/workspace/ cd workspace/ git pull 

and can see testfile.

at point can edit more content , update server again.

echo "test2" >> testfile1.txt git add testfile1.txt git commit -m "test2" git push origin master 

then go first client , git pull see updated file. , can move , forth between 2 computers, , add third if to.

i think, there multiple approaches. describe, how handle this

i have 1 netbook 24/7 server, holds multiple git-repositories. from/to there push , pull changes via ssh. access outside use dyndns.org. works fine, because have more 2 systems, needs access of repositories.

update: little example. lets netbook called "netbook". create repository there

$ ssh username@netbook.local $ cd ~/git $ mkdir newthing $ cd newthing $ git init --bare 

on desktop create clone of it. maybe add files also

$ git clone username@netbook.local:/home/username/git/newthing $ git add . $ git commit -m "initial" $ git push origin master 

on portables (first) same, remote access (from outside lan), add external address.

$ git clone username@netbook.local:/home/username/git/newthing $ git remote add externalname username@mydyndns.home-ip.org:/home/username/git/newthing $ git pull externalname master 

its way git (/git workflows) works. can add many remote repositories like. doesnt matters, if 2 or more refers same "physical" repositories. dont need own local "server", can use public server, have ssh access. , of course dont need public server @ all, if dont need access outside. bare repository can on desktop system , can create working-copy-repository within local filesystem.

$ mkdir myrepo; cd myrepo $ git init --bare $ cd /path/to/myproject $ git remote add origin /path/to/myrepo $ git add .; git commit -m "initial"; git push origin master 

this way, how handle this, , me works quite fine (if not perfect ;))

something read: http://progit.org/ book.-


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -