Steve Steve - 1 year ago 89
Git Question

Working with git in local machine to upload

I am very new with

version control.
I have the project in a directory. I have done these steps:

  • Navigated to the project directory.

  • git init

  • git add .

  • git commit -m "First commit"

And tried to upload to guthub using

git add remote origin

but it gives

fatal: pathspec 'remote' did not match any files

Answer Source

Your syntax to add remote is wrong. The correct syntax is git remote add origin {remote_upstream_name} according to which you have to use

git remote add origin

After you execute this command, you will have origin as remote. You can verify this by executing git remote -v which should display your origin name along with url as:

# Verify new remote
origin (fetch)
origin (push)

Then you can push your changes to the remote origin using following command.

git push -u origin master

Here -u will keep your current branch in sync with your remote branch so from next time you can just do git push and it will push your changes to the remote branch. It also depends on other configs so you have to know about git push see git-push.

Hope this clears your confusions. Let us know if this helps you or not.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download