Git (Version Control) - Upload files to origin repository using the git push command

The most basic way to use Git is to use the git clone command to clone an origin Git repository (such as example.git) to a directory on your PC (such as /home/john.doe/git), make a change to a file in the cloned repository on your PC (such as example.txt), use the git commit command to commit the change to the file, and to then use the git push command to upload the file to the origin Git repository.

 

Let's say you made a change to a file named foo.txt and then used the git commit command to commit the change.

git commit foo.txt

 

The git status command should now show that foo.txt has been modified. At this point, foo.txt in the cloned repository on your PC is different that foo.txt in the origin Git repository.

git status~]# 
# On branch master
#       modified:   foo.txt

 

Notice that the git status command has "On branch master". Likewise, the git branch command with the -a or --all flag can be used to display all of the branches in the cloned repository on your PC. The wildcard character is used to identify the branch you are currently using (master in this example).

~]# git branch --all
  development
* master

 

The git push command can now be used to upload foo.txt to the origin Git repository. In this example, all of the commits in your master branch will be pushed to the origin Git repository.

git push origin master

 

In this example, all of the commits in your development branch will be pushed to the origin Git repository.

git push origin development

 

Something like this should be returned.

Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 431 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
To ssh://git@example.com:7999/path/to/foo.git
   511bd98..4f92bf5  master -> master

 

The -q or --quiet option can be used to suppress all output.

git push --quiet origin master

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.





Please enter 0990c in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |