I understand that the topic probably should have been called somehow differently, but the point is this. There is a bare repository on the server, from where several repository developers are cloned into their local machines. The server also has a client (not bare) repository. When one of the developers makes a commit and a push, the corresponding hook that is attached to the bare repository (post-push hook), pushes the repository to the local server. This is done so that the developers immediately see on the server what and how they changed and who else changed visually in the near future, i.e. right on the site. Everything is convenient, but there is one problem.

Today, we’ll set Developer A to work on folder X, and Developer B on U. B doesn’t intend to enter folder X and change anything there, neither does developer A to change anything in folder U. However, not even despite the fact that they work in completely different directories and on different files, if you don’t do pull before each push, then a conflict arises. Which is obvious, because it’s not the folder that he changed, but the entire repository.

I would like to find such a solution, which would either push only one directory to the server, or with the help of several branches and merge them to achieve the desired result on the server. But weakly imagine how to properly implement one or the other. I will be glad to any help.

And if someone has any other ideas, it will be great too.

    1 answer 1

    Developers A and B will be saved by local branches that they can push to a remote server.

    git checkout -b branchA 

    We write code, commit, etc.

     git push origin branchA:branchA 

    Now our branch is on a remote server and is available to other developers for the pool.

     git pull git branch --track branchA git checkout branchA 

    Now branchA is locally from developer B. You can bullet and watch.

    Everyone works in his own branches until the completion of all the work and until the merge in master does not conflict with anyone.

    • and how to be with that it is necessary still in a local repository on the server to pull it? these branches must somehow be merged there (in the local repository) with each push in the bare repository so that the changes are immediately visible on the site. - luxor
    • After the work is completed, the local brunch is merged into the master and pushed to the server (i.e., to the bare turnip if nothing changes). And then your post-push hook will work. After that, by the way, local and remote branches created by developers can be deleted. - a_gura
    • Of course, this is still a little bit not what I meant, but anyway, thank you very much for your help and feedback! I solved the problem through imitation force pull-a when the post-update hook is triggered. - luxor