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?

This use case is one of the reasons Git is so much better than SVN --> rebase! If you follow good git workflow you rebase from upstream before submitting your Pull Requests. You don't need to worry about file locking and stomping on another person's commits and merge conflicts etc... a rebase sets your work aside, applies the remote commits and then applies your work on top.

I think this just takes a rethinking in your process and relying on the strengths of git versus force fitting a Subversion workflow on top of git. Your "fork-clone" model might need another look as well. Most often every developer has their own fork, you can share repos via remotes between teams if you want. But contributors sharing the same origin sets up some bad habits.

Gitflow is a very popular git workflow, and Github themselves has some nice tips and shares their workflow.

TFS 2017 using Git, lock specific files and folders? : 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� Git LFS locking is a feature that lets developers lock files on the server, preventing their concurrent modification by multiple users of the same repository. With Fork, you can now lock and unlock files from LFS menu in file context menu, avoiding potential binary merge conflicts in LFS files. Show output of git commands in activity manager

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.

Is there a way to lock individual files or directories on fork , With File Locking, you can lock any file or directory, make your changes, and then Your repository contains binary files in which situation there is no easy way to with something specific, and could use community support, post on the GitLab � Git LFS locking is a feature that lets developers lock files on the server, preventing their concurrent modification by multiple users of the same repository. With Fork, you can now lock and unlock files from LFS menu in file context menu, avoiding potential binary merge conflicts in LFS files.

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.

File Locking, Description Ive created a new repository with github desktop( i couldnt When i want to commit i get the error message :A lock file already Watch 1.2k � Star 9.7 k � Fork 5.2k Thanks for understanding and meeting us half way unfortunatly deleting the index.lock file in the git folder didnt do the trick. There is a git remote called origin which I am sure you are all aware of. Basically, you can add as many remotes to a git repo as you want. So, what we can do is introduce a new remote which is the original repo not the fork. I like to call it original. Let's add original repo's to our fork as a remote.

this is possible. git-lfs 2.0 introduces the ability to lock files: see these links: https://github.com/git-lfs/git-lfs/wiki/File-Locking. Support for this feature is available starting from TFS 2017.2: https://docs.microsoft.com/en-us/vsts/release-notes/.

A lock file already exists in the repository, which blocks this , When there's fairly large WIP going on in your working directory, you might Until now, you had to stash all changed files – but now the option to stash individual files is Git LFS locking is a feature that lets developers lock files on the server, One of the ways to do this is binary search through the commit history with git� The git-checkout command can be used to update specific files or directories in your working tree with those from another branch, without merging in the whole branch. This can be useful when working with several feature branches or using GitHub Pages to generate a static project site.

Git does not provide any locking functionality, since it is decentralized. However, if you host your code on GitLab Enterprise Edition Premium, you can use the web interface to lock individual files or folders, achieving exactly what you want to do.

If you do not want to host your project on someone else's server (their website), you can also download GitLab and host it on your own webserver.

Blog - Fork, a directory. Improved. Add context menu for files in the Commit tab Add ability to lock/unlock LFS files. New. Reworked Allow to merge/rebase on remote branches with drag and drop. Fixed Show custom diff view for binary files in working directory. Improved Display how many commits behind or ahead are. New. msdn-code-gallery-community-s-zSdkSoapjs\.git\info\sparse-checkout file in my repositories folder on the disk. git sparse-checkout init in that directory using cmd on windows. The file contents of . msdn-code-gallery-community-s-zSdkSoapjs\.git\info\sparse-checkout is . Sdk.Soap.js/* finally do a . git pull origin master

Release Notes for Mac - Fork, Learn how here. How secure is my code? From there, you'll commit your changes to the repository, making it possible for Enter git add --all at the command line prompt in your local project directory to If you have read access and attempt to edit online, Bitbucket forks the repository, commits your change to the fork,� That is it. It is that simple to encrypt drive with BitLocker in Windows 10. If you looking to protect important files and folder, this is the method you should be using. Lock Folder in Windows 10 - Conclusion. As you can see, there are multiple ways to protect files and folders with a password in Windows 10.

Add, edit, and commit to source files | Bitbucket Cloud, By default the hooks directory is $GIT_DIR/hooks , but that can be changed via the core. The hook is allowed to edit the message file in place, and can be used to working tree and refuse to make a commit if it does not pass certain test . Exiting with a non-zero status from this script causes the git commit command to� If all of the css/ux files are within a particular subfolder, and you want him to have access to everything in that directory, and further down, you could do it with git submodules. The contractor would have push/pull rights to the repo that is a submodule, but no commit rights on the main repo.

githooks Documentation, fatal: not a git repository (or any of the parent directories): .git Initialized your repository with `git init` or by cloning an existing repo. A Git command needs to be run on a specific repository, so this error typically occurs when a Git As you can see, that command spat out a list of local files and folders with a bunch of extra� You need to move to the required path or folder by using the cd command, and the content can be viewed by using the ls command, which will list all of the present files in the directory and in our case you can see the 'README.md' is present. 3. Make a new branch. You can create a new branch by using the git checkout -b 'branch_name'.

Comments
  • I don't feel like file locking is something Git is missing (it's mostly annoying in SVN). In most cases, I'm pretty sure pull request and branching are the way to go for you. You could even separate different part of you project in different repo using submodules, and then you have a much cleaner separation (file protection) between team. So the file owner, would just become the main submodules owner, and he revise every pull request made by his team on his main branch. Then every user have it's own fork.
  • programmers.stackexchange.com/questions/184435/…
  • @SimonBoudrias Your ideas are perfectly non-working if git is used for any document type for which no merge-tool is existing (which is nearly always the case). With TortiseSVN/WebSVN we can avoid MS Exchange, but with git we can't. On my opinion, it is a very unfortunate fallback of the git.
  • Locking binary files using git version control system
  • This works as long as you have mergable files. You are stuck if you have binary files (like Word documents).
  • Git ins't much better than svn and vice versa. Git fits well for a developer who uses non binary files. In our company case for binaries we opted for svn because it handles big binary files (20mb+ with 100+ versions) better than git ( in the scenario we tested) ps: i love git,
  • Down voted because instead of providing a solution, you're convincing people they don't need what they want to do, because Git has something else. If you rebase your changes on top of other people's changes, does it mean there won't be any conflicts (i.e. editing of the same lines) and you surely are not going to overwrite other people's work. I really do not think so
  • @pan40 you can't. Full stop
  • I disagree with this answer because rebase is not the panacea to handling conflicts, even worse! The purpose of SVN lock, unless one tricks with the working copy or abuses the force steal lock, is to warn people that somebody is doing large modifications to a file. In a Git rebase, if one applies multiple commits to the same file modified by others, he will have to solve conflicts for each and every commit to replay. Merge will be cheaper in that case because you solve conflicts once, but that is not the purpose of locking. Surely, a good project management and coordination helps
  • This is the correct answer. Not the one accepted at this time of writing. Upvoted. It doesn't even have to be binary files for locking to be necessary. Take the comment on the iOS storyboards on the other question for instance.