user1868943
user1868943

Reputation:

Add a removed existing remote to a git repository

I accidentally performed a git remote rm <remote_repo_name> :( Will a git remote add remote_repo_name <remote_repo_path> add it back as a remote even though the remote already had previously pushed content ?

Upvotes: 1

Views: 68

Answers (2)

CharlesB
CharlesB

Reputation: 90316

Yes!

When you deleted the remote, git just removed it from the list of known remotes (located in .gitconfig). Adding it again will do the exact reverse operation.

Your remote references (origin/master and such) are not modified in any case, and the fact that you push content doesn't have anything to do.

Upvotes: 0

Borealid
Borealid

Reputation: 98469

Yes.

git remote add just tells your repository about the remote repository. It doesn't do anything with the content of that repo. So git remote rm and git remote add are inverse operations.

When you do a git fetch, git will be smart enough not to download the stuff you already have locally again. This is a consequence of how git works under the hood and not really relevant to your question; you should just know that you've lost nothing by accidentally removing the remote.

Upvotes: 2

Related Questions