Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to lock individual files or directories on fork when using git?

We are a team of 60+ developers working on the same product and are moving from SVN to Git and GitHub. We have a process in SVN where in individual files are locked and whenever a developer wants to commit code, he needs to get it unlocked by the owner of the file. Three of us are the owners of the total 150+ files. The unlocking is preceded by a code review.

In Github, we are planning to use the Fork-Clone model - each project a group of dev is working on will do a fork, each developer will do a clone of the fork, write the code & commit to origin, the lead of the feature will do a pull request to upstream.

Though this seems fine, the problem is when a big project gets delivered, it brings in lots of changes for review and hence, increases the load for the file owners. Also, this might happen in the later cycles of development and hence the project might be jeopardized.

One method we thought might work is to have hooks when the git push is done to the origin (fork). There can be one final review git pull to upstream.

However, we could not find any github extensions or push hooks for the same. Is there a quick way (read, existing extension) to do this with Github or should we use the same hooks that we would use with git?

like image 838
Karthick S Avatar asked Dec 01 '12 18:12

Karthick S


People also ask

How do I lock a file in a git repository?

lock file manually via this command or a similar command on your operating system: rm . git/index. lock .

What is index lock file in git?

When you perform a Git command that edits the index, Git creates a new index. lock file, writes the changes, and then renames the file. The index. lock file indicates to other Git processes that the repository is locked for editing.

How do I lock a file in bitbucket?

We need to tell Git which files to track as large files by the LFS using the git lfs track command. If you want to be able to 'lock' these files, you must also include the --lockable flag. This needs to be done for each repository.


2 Answers

No chance, if file is not mergeable and you need to lock it, use a centralized solution instead of GIT, i.e. SVN or ClearCase.

like image 82
user5694595 Avatar answered Oct 02 '22 04:10

user5694595


If you are using git LFS (which is supported by some git hosting providers, like GitHub) you could use File Locking.

Mark a file type as lockable by editing the .gitattributes file:

*.docx lockable # Make MS Word files lockable 

And lock it with:

$ git lfs lock example.docx 

You can unlock your files with git lfs unlock example.docx and those of somebody else by adding --force.

like image 32
Nijin22 Avatar answered Oct 02 '22 03:10

Nijin22