Everywhere I look, all I see is the standard:
git add remote origin <url>
followed by: add/commit/push
I do not want to add, commit and push anything. I just want to link my remote repository, and then be able to change branches, so I can create a new branch inside my repository, and then push stuff in it. Currently, when I do the git add remote origin <url>
, and then do git branch
, I see nothing. git branch -r
also does not nothing. Why? Where are all my branches? If I do git checkout master
, it doesn't work.
What I want is to do the same thing as cloning a repo, but instead of cloning it, I want to link it to my project. I do not want to commit or push anything into my master branch.
How do I connect it?
CodePudding user response:
The reason you do not see the branches of your remote repository in you local repository is that you missed the call to git fetch
.
Do a
git add remote origin <url>
git fetch origin
git branch -r
and you will see the remote branches in you local repository. You can then checkout to one of them by running
git checkout -b <branch name>
After that it is the usual add/commit/push
workflow again.