I have cloned an ongoing sample project repo from git and its main branch is 'master'. But this repo has all changes uptodate in branch 'develop' and only a 'README.md' file in 'master' branch. I got the master branch cloned using https. I need to get the changes in 'develop' branch. Please help me to figure out.
4 Answers
But this repo has all changes uptodate in branch '
develop
' and only a 'README.md
' file in 'master
' branch
Then clone directly the right branch with git clone -b
:
git clone -b develop https://url/of/repo

- 1,262,500
- 529
- 4,410
- 5,250
Try this -
This command fetches all branches from remote.
git pull --all
This command checkouts the requested branch (if it is present)
git checkout develop

- 510
- 2
- 9
-
This partially helped to solve my problem by using 'git checkout develop'. Initially when I tried to do so, I got detached state which confused me. Thanks for the help. – newbie Feb 20 '19 at 04:59
It sounds like you are trying to merge changes from the develop branch to the master branch. Have a look at https://www.git-scm.com/docs/git-merge to see if that helps.

- 63
- 2
- 10
-
Basically Im not trying to merge, but trying to get the checkout to develop branch to get the changes. I don't need want to merge this to master branch – newbie Feb 20 '19 at 04:53
When you download a git repo from say GitHub it is defaulted to master
. To view a new branch you can checkout
to a branch.
Assuming you know the git basics
git checkout <branch-name>
So you should be doing
git checkout develop
Extra
To view all remote branches
git branch -r
To list your local branches
git branch
To pull changes from remote
to your working tree
git pull #pull downloads "all" by default
To only download all the changes in remote but not to your working tree (the branches you're tracking)
git fetch

- 3,417
- 2
- 18
- 42