Can I use git to manage the site even if other people update it without using git?

So, let's say I have a web server that I can access via ftp. Most people update it using Dreamweaver, and I update mainly by copying and pasting manually between my computer and the server. My question is: can I use git to manage the site (and do not need to manually copy / paste) while other people update it using other methods?

  • I can not install much on the server. I would only like to put the files on the server to install this.
  • I do not want to manually copy and paste to upload to the server.
  • I don't want to unintentionally undo others' changes without using git, and I don't want them to use git.
    • At the same time, if I and others will edit the website at the same time, I would like to take advantage of the git merge features.

How do I configure this? (Also, what scripts could I put on my computer to make it easier (both hooks and without hooks)? (I would know how to make them, I just want the tips to be like what I had to do for this workflow.))

Note. I use linux if that matters. (Also, I am using git from the command line).

Note. I do a great job of performing some manual actions that are usually not needed (for example, turning my teammates into commits). I want to avoid manually copying and pasting.

+3
source share
4 answers

What you can do without installing git on the server is maintaining a local copy of the rsync'ed server website on the local computer.
If your server supports sftp, you can use csync (without having to install it on the server side): it is better than rsync and bi-directional.

Then you can have your own git repository, and whenever you want to add or compare changes from a website, you can switch the branch and do:

git --work-tree=/path/to/csync/folder status . 

Compare the current current repo index and the synchronized local folder that reflects the website.

You have two branches in your git repository, one for your current job and one for including the website in the repo.

You can combine the two locally, and when you are ready, you will check the repo using the csync'ed folder as a working tree

 git --work-tree=/path/to/csync/folder checkout HEAD -- . 
+2
source
  • Somehow setting up a method on which you can run git commands (on your computer) that affect the FTP server, as well as the ability to click on the FTP server (for example, using rsync / csync , installing the ftp server locally or this in combined with some initial copy and paste).
  • On the git repo server, set receive.denyCurrentBranch to updateInstead using the git config receive.denyCurrentBranch "updateInstead" . See Click to expand .
  • Now, when you click on your local repo on the server, if the server has been modified, you will get an error similar to this
      !  [remote rejected] master -> master (Working directory has unstaged changes) error: failed to push some refs to '../remote'
    
    To solve this problem, you must commit the changes made by your teammates to the remote server. You might want to make cherries. Then go to step 4.
  • If the local server is synchronizing with the git branch, you just click on it, it will also be updated. (Keep in mind that you still need to do things like do git pull before git push , etc.)
+1
source

I use two servers on one website for this purple. Production using only FTP access and development with full access. I click on the development server where I have a post-receive script that checks bare repos on a temporary folder, and does not call a Python script that uploads the code to FTP. I do not know how to allow other users to use FTP. You really have to tell them to use git, it will be easier for everyone, and you will also have much better control over the code. If you have this setting, you can only have one branch that will click on the production server, while others will simply evolve.

0
source

I did not do this to understand how useful it can be, but you can mount the remote directory using, for example, curlftpfs. I expect this to give you several alternatives to using it:

  • Unmodified, contains only working files and locally stores the repository (i.e. .git contents) in the directory specified by the GIT_DIR environment GIT_DIR . core.worktree must be configured to mount ftp.
  • You can use it as a real repository with a subdirectory .git , do git init , etc.
  • Have a .git file in it instead of the GIT_DIR variable.
  • Be able to manage with git worktree after some manual configuration, as there is currently no automatic conversion of the existing directory to the working line.

Much depends on whether you are the only git user or if you are concerned about your personal changes to the ftp directory.

0
source

Source: https://habr.com/ru/post/1240248/


All Articles