Bash – How Do I Make A Bash Script for Git Checkin/Checkout

bashgit

I was thinking of bringing up a git service on an Ubuntu server. However, the way me and another programmer operate — we really want to try and stick to one person working on a project at a time.

How would I make a Bash script to create a check in and check out with git? We want to prevent anyone from checking in code that hasn't already been checked in, and it should error out with the name of the person who has the code checked out.

EDIT: I'm not really interested in using Git with its fantastic diff features. I move 100mph and don't have time to play diff games with the other developers. That's why we're using Git. If the other developers want to play the diff game, they can still do so. But when I check something out, I want it locked to everyone until I check it back in again.

Best Answer

But when I check something out, I want it locked to everyone until I check it back in again.

Errr... sorry, this isn't how a DVCS (with a D as "Distributed") works at all.

a/ you don't "checkout" a file (like you would in ClearCase for instance). You just start modifying it, and Git will detect the change as a candidate for indexing (git add) and for committing (git commit, the "checking" part)

b/ When you "checkout" (i.e. modify) or checking a file, the other developers, with their associated other repos, don't know anything about that.
You "locking" everybody in that everybody can't access your repo and modify your files.

But when you publish (i.e push those changes), then you need to solve any concurrent modification. In a DVCS, there is no central referential able to detect a concurrent change and/or to record a "lock".