How to setup GIT to replace FileZilla

I am struggling to get GIT to replace FileZilla.

The basic idea is to a GIT Server on my Domain Server a URL.

REMOTE SERVER Directory Structure

/var/www/URL-001.com/public_html
/var/www/URL-002.com/public_html
/var/www/URL-003.com/public_html

LOCALHOST SERVER Directory Structure

/home/john/www/URL-001.com/public_html
/home/john/www/URL-002.com/public_html
/home/john/www/URL-003.com/public_html

How do I setup Git on the REMOTE SERVER so that I am able to Git clone into the LOCALHOST directory structure.

REMOTE SERVER and LOCALHOST

  1. Set git user:name, user:email and user:password
  2. cd
  3. git init
  4. git status
  5. git add .
  6. git commit -m “message goes here”

I am able to “git clone userName@URL-001.com:/var/www/public_html” OK but…

when I make changes to the LOCALHOST /home/john/URL-001/public_html/ the changes are added and committed OK but cannot be pushed?

Any suggestions?

Hi John,

I found this tutorial very useful when I was trying to do the same thing: https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps

The nice thing about the setup described is that the files are deployed separately from the git repo itself, which is cleaner.

2 Likes

@fretburner

Many thanks for the link. I tried the tutorial but still could not get git to work.

I have managed to solve one of the problems which was due to the online file not having shared access. A new installation now created with the following:

git init --bare shared=true

That managed an extra step on the ladder and can now locally git clone … the online repository files and directories and upload the local changes:

git push

Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 295 bytes | 295.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To 123.456.789.876:/var/www/URL-001.com/public_html/.git
   ad41a71..50e8400  master -> master

BUT where they go nobody knows :frowning: The online files do not change.

Enough for one day, hopefully continue tomorrow.

Edit:
Removed duplicated text.

I tried again and was delighted to get it to work. Paths were the problems and misleading error messages, which I Googled and dug myself deeper into a hole with an unfathomable depth :frowning:

Working on my LOCALHOST requires opening a Command Window, navigate to the project folder:

  1. Setup git // https://git-scm.com
  2. git clone <online site> // only required once to download all the online files
  3. git add . // notice the trailing period to initially add ALL files to the project
  4. Locally edit (and create new files and/or folders)
  5. git status // to view only changes
  6. git commit -ma // to commit changes ready for uploading/pushing
  7. git push // to upload only modified files and folders
  8. Locally browse ONLINE site and view rendered changes

Very Important:
Further file modifications only require items 5 and 6 to upload changed files.

Upload process is virtually instant, far quicker than FleZilla. Goodbye ver-001, ver-002, ver-003, etc :slight_smile:

Also I believe that working/editing files on another computer is possible. I have yet to investigate many of the numerous features, especially rollback to a previous version.

Note:
Git (not to be confused with https://github.com) is installed on the Linux Apache2 Ubuntu Remote Server and also on my working computer. Macs and Windows can also have a local Git installation and perform the same tasks to the remote server.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.