how to push to git from Terminal / Command Line

53,572

Solution 1

next thing would be to commit using and then push to what ever branch you want to push

git commit -m 'Some message about the change'

git push origin 'branch-name'

Solution 2

Turns out it is that simple:

cd /Users/mainuser/Desktop/YourFolder
git add -A .
git commit -m 'commit message from terminal'
git push

Edit: if you use just git commit without -m, you will enter some editor to type commit message, which I don't know how to quit.

Solution 3

Try the following cmd:

$ git status
$ git add <file_name>
$ git commit -m "<msg>"
$ git push origin <branch_name>
Share:
53,572
sanjihan
Author by

sanjihan

Updated on July 09, 2022

Comments

  • sanjihan
    sanjihan almost 2 years

    I added a file into the folder for Git uploading. I can see the folder in the SourceTree under unstaged. How can I push the file to online storage with terminal commands?

    I figured it out I need to first cd to the local repository, which I did with this:

    cd /Users/mainuser/Desktop/Projects
    git add -A .
    

    checked status with git status and it outputs this:

    On branch master
    Your branch is up-to-date with 'origin/master'.
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)
    
        new file:   ios_projects/2016/Untitled copy 2.rtf // this is the file I want to upload
    

    What now? How do I commit it and push it online?

  • sanjihan
    sanjihan about 8 years
    Thats great! Do you perhaps know how to commit current date and time as commit message?
  • Shani
    Shani about 8 years
    hmm not really, you can surely manually add date and time to the commit message. I do know that you will surely see the commit date in your commit log or when you go to git commit tab. Hope that helps