J. zhao
J. zhao

Reputation: 43

Add code to existing repository

I already create a repository and push some code to it on GitHub. Now I made some changes and want to push the new codes. However, when I use "git remote add origin https://github.com/xx/xxx.git", it throws error "fatal: remote origin already exists."

I also tried "git remote add github https://github.com/xx/xxx.git", returns the same error.

How should I fix it? Thank you all in advance.

Upvotes: 0

Views: 1269

Answers (1)

Emily
Emily

Reputation: 385

It seems that you're mixing up git add and git remote add.

git add adds files to staging; ie., indicates which files you would like to commit next. This is what you want to use. After that, you'll want to use git commit -m 'commit message goes here' to combine the added files in one commit, and then git push to push it to your remote repository.

git remote add adds a new "remote" repository location to your local one. You presumably already did this once for that Github repo, hence why git is telling you the remote already exists. You don't need to do it ever again.

Upvotes: 1

Related Questions