Push Files or Folders to a Git Repository

Posted on

This is an article written for describing on how to push files or folders to a remote Git repository server. So, the folder or the files which is going to be operated further which is located inside the already associated or initialized folder can be pushed further and is being synchronized between the local Git repository folder with the one exist in the remote Git repository server. To be able to push files or folders to a Git repository there are few steps need to be taken before it can be executed. Below are those steps :

1. Install git utility in the machine where the folders and files which is going to be pushed are located.

2. After successfully install git utility, select the main folder which is used to store the folders and files which are going to be pushed.  In other words, the folder will be initialized and associated with the Git version control. Read the article titled ‘Setup a Git Repository via Command Line‘ in this link to find out how.

3. Soon after the 2nd step has been carried out successfully, just add the folders and files in the already initialized or assciated with Git version control to be added in the index of local Git repository. The information is provided in the article titled ‘Add Files or Folders to Git Repository‘ in this link.

4. Another step which is also important after executing the one which is shown in the 3rd step, it is performing commit operation on the already added files or folders located inside the folder which is associated with Git version control. To know how to do it, check the article titled ‘Commit Files or Folders to Git Repository‘ in this link.

5. Finally, the last step for pushing the folders or files existed in the Git version control associated or initialized folder has come. To achieve that purpose, just type the following command pattern :

git push --set-upstream repository-label-name branch-name

Description : 
git : It is the command for executing Git version control
push : It is specifying an additional parameter for pushing the files or folders which has already been committed locally inside an already associated or initialized folder with a Git version control. 
--set-upstream : it is an additional command parameter for giving the information of the branch which is used to operate from
repository-label-name : it is a string characters given to define the branch's name locally
branch-name : it is 

Based on the above command pattern, below is the real example of using the command :

user@hostname:~/test$ git push --set-upstream myapp master
Username for 'http://srv.app.repository': myuser
Password for 'http://myuser@srv.app.repository':
Counting objects: 44, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (44/44), done.
Writing objects: 100% (44/44), 25.72 MiB | 1.24 MiB/s, done.
Total 44 (delta 7), reused 0 (delta 0)
To http://srv.app.repository/gitlab/myapp/local-app.git
dffc2a7..76ddede master -> master
Branch master set up to track remote branch master from myapp.
user@hostname:~/test$

In the above example, ‘myapp’ is the repository name defined in the process of adding git remote URL repository server. The last value passed which is part of the command executed, ‘master’ is the name of the branch which is selected as the push target. Basically a Git version control initiated will have a master branch at first and at minimum.

Leave a Reply