sanjihan
sanjihan

Reputation: 5992

how to push to git from Terminal / Command Line

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?

Upvotes: 19

Views: 112924

Answers (4)

Himanshu Chauhan
Himanshu Chauhan

Reputation: 1

Enter Your Terminal and Write Below Commands

git commit -m "Enter What should you Save as a Description"

And You Should push or commit with the Visual Studio code Editor also Just go in and left side Source Control menu either press it ctrl+Shift+g and Commit or push after init Repository.

Upvotes: 0

Maths RkBala
Maths RkBala

Reputation: 2195

Try the following cmd:

$ git status
$ git add <file_name>
$ git commit -m "<msg>"
$ git push origin <branch_name>

Upvotes: 5

sanjihan
sanjihan

Reputation: 5992

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.

Upvotes: 17

Shani
Shani

Reputation: 2541

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'

Upvotes: 26

Related Questions