How can we push files in a local Git repository in a folder which is already associated or initiated with Git version control to a remote FTP server ?. It can be done easily by installing a specific package or utility. So, Git utility can be used to push files to an FTP Server but in this case there will be an additional package or utility which is needed to be installed.
Don’t forget to check whether or not the folder which the files or folders inside of it are going to be pushed has already been associated or initiated with Git version control. Read the following article titled ‘Setup a Git Repository via Command Line’ in this link to get more information about it. Off course the most important thing before performing setup a local Git Repository via command line is installing the Git utility itself.
After installing Git utility itself, don’t ever forget to add or to install the additional package or utility specified before to be able to push the files or folders in a local Git repository to an FTP server. The name of the package or utility is ‘git-ftp’. Depends on the operating system, the package or utility can be installed in many ways. So, these are steps taken to accomplish the tasks :
1. Install ‘git-ftp’ and in this article’s context, it is the installation process in an Ubuntu Linux distribution :
apt-get install git-ftp
This is an output generated when the above command is executed to install ‘git-ftp’ in an Ubuntu Linux distribution :
user@hostname:~# apt-get install git-ftp Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: git-ftp 0 upgraded, 1 newly installed, 0 to remove and 938 not upgraded. Need to get 15,7 kB of archives. After this operation, 81,9 kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 git-ftp all 1.0.2-1 [15,7 kB] Fetched 15,7 kB in 2s (5.991 B/s) Selecting previously unselected package git-ftp. (Reading database ... 910975 files and directories currently installed.) Preparing to unpack .../git-ftp_1.0.2-1_all.deb ... Unpacking git-ftp (1.0.2-1) ... Processing triggers for man-db (2.7.5-1) ... Setting up git-ftp (1.0.2-1) ... user@hostname:~# exit
As shown in the manual page of ‘git-ftp’ it is given a short and valuable information of its function and that is ‘Git powered FTP client written as shell script’.
2. After successfully installed ‘git-ftp’, define the following parameter which is really needed to be able to push source of files or folders to a remote FTP server :
user@hostname:~/test$ git config git-ftp.user myself user@hostname:~/test$ git config git-ftp.password mypassword user@hostname:~/test$ git config git-ftp.url ftp://xxx.xxx.xxx.xxx/mydrive/source-code
3. After installing the utility named ‘git-ftp’, the process for pushing the files to an FTP server will be handled by the execution of the command ‘git-ftp push’. This the command :
And it can be shown for an example below :
user@hostname:~/test$ git-ftp push There are 64 files to sync: [1 of 64] Buffered for upload 'Access-Guide/Manual-Access.docx'. [2 of 64] Buffered for upload 'Access-Guide/Manual-Access.pdf'. ... Uploading ...
There are rules which is a must for executing the above command and it must be done before. Those steps are :
1. Install git utility.
2. Associate and initialize the folder with Git version control. It is the folder where files and folders located inside of it are going to be synchronized with the Git repository server. It is defined in the previous article titled ‘Setup a Git Repository via Command Line‘ in this link.
3. Add the files or folders located inside of the local Git repository folder. To be able to understand how to do it, just read the article in this link which titled ‘Add Files or Folders to Git Repository‘.
4. Don’t forget to commit the files or folders which has already been added. To retrieve the general description on how to do it, check the article titled ‘Commit Files or Folders to Git Repository‘ in this link.
5. Add an URL repository server which is used as the target repository server. Read the article ‘Add Remote URL Git Repository via Command Line‘ that can be visited in this link.
6. Push the files or folders to the repository which has already been defined in the 5th step.
7. Synchronize the local folder with the remote Git repository server so that the local folder. In other meanings, the local Git repository folder are synchronized with the remote Git repository folder.
After performing those steps above, just execute ‘git-ftp push’ to push all files or folders to the FTP server selected as target.