-4

Suppose, I have a Github repository as C-Basics. In that repository, I have a branch named as main. And, in the main branch I have previously added a file main.c. Now if I want to add a file first.c to the main branch or wanna update the main.c file, which Git commands are used for this?

Irfan wani
  • 4,084
  • 2
  • 19
  • 34
  • 2
    [This](https://git-scm.com/book/en/v2) is a very good ressource to learn using git ;) – limserhane Feb 25 '21 at 08:58
  • Does this answer your question? [git - remote add origin vs remote set-url origin](https://stackoverflow.com/questions/42830557/git-remote-add-origin-vs-remote-set-url-origin) – Irfan wani Feb 25 '21 at 09:23
  • I recommend searching for tutorials on basic Git commands and working with Github. Here is the tutorial from the Git book: [Recording Changes to the Repository](https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository), [Working with Remotes](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes) – Gino Mempin Feb 25 '21 at 11:21

1 Answers1

1

First of all you should set this github repo as the repo for the new file to be uploaded.

In your cmd, go to the location of the file and type this command;

git remote add origin url_of_your_repo.git

The above command works when the local file is not a git repository.

If you want to shift a git repo to another repo;

git remote set-url origin url_of_your_repo.git
Irfan wani
  • 4,084
  • 2
  • 19
  • 34