Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Appropriate Git workflow for thesis with server involved

Tags:

git

workflow

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.

like image 232
absurd Avatar asked Feb 14 '26 02:02

absurd


2 Answers

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:

git clone ssh://username@servername:/path/to/bare/repo.git

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:

git add .
git commit -m 'Made some changes'

Then you just do:

git pull

when you want to update, and:

git push

when you want to push the changes you've committed locally to the server.

like image 187
11101101b Avatar answered Feb 16 '26 14:02

11101101b


No, you don't create repositories on each computer. You create the repo on one computer, push to the central repo and then clone from there on the others.

Easiest solution:

Laptop A:  leave alone
Laptop B:  change name of existing git repository to retain it as a backup.  Then `git clone <url>` from central repo
Desktop:  same as laptop B

Once you're confident you've got the repository cloned and the file(s) are correct, you can delete the renamed original repository.

Your workflow from then on whenever moving to a computer:

git pull (to receive any changes you pushed while on a different computer.  If it exits silently, there were no changes)
work, work, work
git add .
git commit -m <comment>
git push
like image 30
wadesworld Avatar answered Feb 16 '26 16:02

wadesworld



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!