Questions tagged [branch]

A "branch" is a term used in version control systems to represent an independent line of development. Depending on the system, a repository can contain one or more branches. Branches are merged when changes need to propagate from one branch into another.

A "branch" is a term used in version control systems to represent an independent line of development. Depending on the system, a repository can contain one or more branches. Branches are merged when changes need to propagate from one branch into another.

Source: Wikipedia Branch (Version Control)

Related tags:

5403 questions
1008
votes
27 answers

How do I clone a single branch in Git?

I have a local Git repository in ~/local_repo. It has a few branches: $ git branch * master rails c c++ To clone the local repository, I do: $ git clone ~/local_repo new_repo Initialized empty Git repository in…
Casey Rodarmor
  • 14,878
  • 5
  • 30
  • 33
887
votes
16 answers

Pull a certain branch from the remote server

Say that someone created a branch xyz. How do I pull the branch xyz from the remote server (e.g. GitHub) and merge it into an existing branch xyz in my local repo? The answer to Push branches to Git gives me the error "! [rejected]" and mentions…
tybro0103
  • 48,327
  • 33
  • 144
  • 170
875
votes
22 answers

How do I list all remote branches in Git 1.7+?

I've tried git branch -r, but that only lists remote branches that I've tracked locally. How do I find the list of those that I haven't? (It doesn't matter to me whether the command lists all remote branches or only those that are untracked.)
James A. Rosen
  • 64,193
  • 61
  • 179
  • 261
857
votes
6 answers

When does Git refresh the list of remote branches?

Using git branch --all shows all remote and local branches. When does Git refresh this list? On pull/push? And how do I refresh it using Git Bash?
BendEg
  • 20,098
  • 17
  • 57
  • 131
854
votes
3 answers

How to commit my current changes to a different branch in Git

Sometimes it happens that I make some changes in my working directory, and I realize that these changes should be committed in a branch different to the current one. This usually happens when I want to try out new things or do some testing and I…
Auron
  • 13,626
  • 15
  • 47
  • 54
853
votes
10 answers

How to "git pull" from master into the development branch

I have a branch called "dmgr2" in development, and I want to pull from the master branch (live site) and incorporate all the changes into my development branch. Is there a better way to do this? Here is what I had planned on doing, after committing…
Matthew Colley
  • 10,816
  • 9
  • 43
  • 63
850
votes
5 answers

View a file in a different Git branch without changing branches

Is it possible to open a file in a git branch without checking out that branch? How? Essentially I want to be able to open a file in my github pages branch without switching branches all the time. I don't want to modify it, just want to view it.
Schneems
  • 14,918
  • 9
  • 57
  • 84
834
votes
13 answers

How do you remove an invalid remote branch reference from Git?

In my current repo I have the following output: $ git branch -a * master remotes/origin/master remotes/public/master I want to delete remotes/public/master from the branch list: $ git branch -d remotes/public/master error: branch…
cmcginty
  • 113,384
  • 42
  • 163
  • 163
774
votes
11 answers

How do you stop tracking a remote branch in Git?

How do you stop tracking a remote branch in Git? I am asking to stop tracking because in my concrete case, I want to delete the local branch, but not the remote one. Deleting the local one and pushing the deletion to remote will delete the remote…
Jason Cohen
  • 81,399
  • 26
  • 107
  • 114
757
votes
14 answers

Set up git to pull and push all branches

I'd like to push and pull all the branches by default, including the newly created ones. Is there a setting that I can define for it? Otherwise, when I add a new branch, locally and I want to pull it from the server, what is the simplest way to do…
lprsd
  • 84,407
  • 47
  • 135
  • 168
732
votes
1 answer

How do I create a new Git branch from an old commit?

Possible Duplicate / a more recent/less clear question Branch from a previous commit using Git I have a Git branch called jzbranch and have an old commit id: a9c146a09505837ec03b. How do I create a new branch, justin, from the information listed…
JZ.
  • 21,147
  • 32
  • 115
  • 192
719
votes
14 answers

How is a tag different from a branch in Git? Which should I use, here?

I am having some difficulty understanding how to use tags versus branches in git. I just moved the current version of our code from cvs to git, and now I'm going to be working on a subset of that code for a particular feature. A few other developers…
Bialecki
  • 30,061
  • 36
  • 87
  • 109
697
votes
10 answers

How do I merge my local uncommitted changes into another Git branch?

How can I do the following in Git? My current branch is branch1 and I have made some local changes. However, I now realize that I actually meant to be applying these changes to branch2. Is there a way to apply/merge these changes so that they become…
solsberg
  • 7,875
  • 4
  • 22
  • 12
666
votes
10 answers

How do I create a branch?

How do I create a branch in SVN?
sparkes
  • 19,343
  • 5
  • 39
  • 46
597
votes
10 answers

Using Git, show all commits that are in one branch, but not the other(s)

I have an old branch, which I would like to delete. However, before doing so, I want to check that all commits made to this branch were at some point merged into some other branch. Thus, I'd like to see all commits made to my current branch which…
sircolinton
  • 6,536
  • 3
  • 21
  • 19