Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git - pulling from specific branch

Tags:

git

People also ask

Can you pull a specific branch in git?

You can only use pull if you want to merge another branch into the already checked out branch or if you want to update an already checked out branch.

How do I fetch a specific branch?

just need to run git fetch , which will retrieve all branches and updates, and after that, run git checkout <branch> which will create a local copy of the branch because all branches are already loaded in your system.

How do I pull a remote branch to a local branch?

If you want to merge a remote xyz branch into a local xyz branch, where both branches exist off a master branch in a remote and local repository, just select or "checkout" the local xyz branch first, then do a "pull" on the same remote branch.

How do I pull a branch from github?

The simple command to PULL from a branch is: git pull 'remote_name' 'branch_name' .


See the git-pull man page:

git pull [options] [<repository> [<refspec>...]]

and in the examples section:

Merge into the current branch the remote branch next:

$ git pull origin next

So I imagine you want to do something like:

git pull origin dev

To set it up so that it does this by default while you're on the dev branch:

git branch --set-upstream-to=origin/dev dev

Here is what you need to do. First make sure you are in branch that you don't want to pull. For example if you have master and develop branch, and you are trying to pull develop branch then stay in master branch.

git checkout master

Then,

git pull origin develop

It's often clearer to separate the two actions git pull does. The first thing it does is update the local tracking branc that corresponds to the remote branch. This can be done with git fetch. The second is that it then merges in changes, which can of course be done with git merge, though other options such as git rebase are occasionally useful.


Here are the steps to pull a specific or any branch,

1.clone the master(you need to provide username and password)

       git clone <url>

2. the above command will clone the repository and you will be master branch now

       git checkout <branch which is present in the remote repository(origin)>

3. The above command will checkout to the branch you want to pull and will be set to automatically track that branch

4.If for some reason it does not work like that, after checking out to that branch in your local system, just run the below command

       git pull origin <branch>