I’m just starting to use git for my thesis and my question is what will be an appropriate workflow for me.
Here my prerequisites:
Hardware used:
- Laptop A used at home
- Laptop B a netbook used when I’m in the library
- Desktop computer at university
- Private filespace on a server of my university which also runs git (preinstalled by the university, nice, isn’t it?)
What I did until know is writing my thesis with LaTeX and copying it between all these computers by hand. It often happens that I’m writing sth. on one machine but then I have a day off and I don’t know where’s my most recent version. In these cases I used diff to compare and find out what document is the most recent one.
A little bit of reading about git showed me that it would help me a lot.
I thought of something like having a central repo at the server and pushing/pulling to/from it with all the computers.
I now have created a bare repo on the server and I have created local repositories (by git init) on each of the computers.
But I’m not sure if this was right:
Right now all computers are in sync so all local repos contain the same files/versions. I have pushed to the bare repo on the server from my Laptop A.
I tried to pull from the server repo to my Desktop computer:
git pull origin master
output:
* branch master -> FETCH_HEAD
Merge made by the 'recursive' strategy.
That created a branch on my Desktop computer, if I understood it correctly. Should I apply any further operations after this before I start working on the desktop pc?
Another try was:
git pull origin master:master
output:
! [rejected] master -> master (non-fast-forward)
As far as I read it in the Git book that’s an expected behaviour though I can’t say why. Wouldn’t this prevent that a new branch is created each time I pull?
Anyway, I now read over many posts here on stackoverflow and also some chapter in the official git book, but I must say, my head is humming a little bit.
I don’t know if the workflow I started here is correct at all for what I want to achieve. Maybe I should not use the server git but just clone to the filespace?
Could somebody get me on the right track?
Thanks a lot.
After creating your bare repo on the server, instead of running git init on each of the computers, you should clone from the bare repo on the server. For example, if you are using ssh protocol you could do something like this on each of the other computers:
That will automatically set your origin remote to the server with the bare repo. You can then make all the changes you want on your local computer, commit your changes locally with something like this:
Then you just do:
when you want to update, and:
when you want to push the changes you’ve committed locally to the server.