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
590
votes
28 answers

How to find the nearest parent of a Git branch

Let's say I have the following local repository with a commit tree like this: master --> a \ \ develop c --> d \ \ feature f --> g --> h master is my this is the latest stable…
Peter Farmer
  • 9,020
  • 5
  • 27
  • 29
581
votes
27 answers

Finding a branch point with Git?

I have a repository with branches master and A and lots of merge activity between the two. How can I find the commit in my repository when branch A was created based on master? My repository basically looks like this: -- X -- A -- B -- C -- D -- F …
Jochen
  • 7,270
  • 5
  • 24
  • 32
576
votes
16 answers

Fix GitLab error: "you are not allowed to push code to protected branches on this project"?

I have a problem when I push my code to git while I have developer access in my project, but everything is okay when I have master access. Where is the problem come from? And how to fix it? Error message: error: You are not allowed to push code to…
567
votes
10 answers

How do I run git log to see changes only for a specific branch?

I have a local branch tracking the remote/master branch. After running git-pull and git-log, the log will show all commits in the remote tracking branch as well as the current branch. However, because there were so many changes made to the remote…
Highway of Life
  • 22,803
  • 16
  • 52
  • 80
553
votes
12 answers

Git undo local branch delete

I just deleted the wrong branch with some experimental changes I need with git branch -D branchName. How do I recover the branch?
Stefan Kendall
  • 66,414
  • 68
  • 253
  • 406
521
votes
35 answers

Your configuration specifies to merge with the from the remote, but no such ref was fetched.?

I am getting this error for pull: Your configuration specifies to merge with the ref 'refs/heads/feature/Sprint4/ABC-123-Branch' from the remote, but no such ref was fetched. This error is not coming for any other branch.The special thing…
Farrukh Chishti
  • 7,652
  • 10
  • 36
  • 60
518
votes
5 answers

What are the differences between git branch, fork, fetch, merge, rebase and clone?

I want to understand the difference between a branch, a fork and a clone in Git? Similarly, what does it mean when I do a git fetch as opposed to a git pull? Also, what does rebase mean in comparison to merge? How can I squash individual commits…
jackiekazil
  • 5,696
  • 4
  • 21
  • 20
493
votes
11 answers

How do I see the commit differences between branches in git?

I'm on branch-X and have added a couple more commits on top of it. I want to see all the differences between MASTER and the branch that I am on in terms of commits. I could just do a git checkout master git log and then a git checkout…
Son of the Wai-Pan
  • 12,371
  • 16
  • 46
  • 55
477
votes
12 answers

Show just the current branch in Git

Is there a Git command equivalent to: git branch | awk '/\*/ { print $2; }'
Ollie Saunders
  • 7,787
  • 3
  • 29
  • 37
474
votes
16 answers

How to determine when a Git branch was created?

Is there a way to determine when a Git branch was created? I have a branch in my repo and and I don't remember creating it and thought maybe seeing the creation timestamp would jog my memory.
oz10
  • 153,307
  • 27
  • 93
  • 128
474
votes
6 answers

Depend on a branch or tag using a git URL in a package.json?

Say I've forked a node module with a bugfix and I want to use my fixed version, on a feature branch of course, until the bugfix is merged and released. How would I reference my fixed version in the dependencies of my package.json?
hurrymaplelad
  • 26,645
  • 10
  • 56
  • 76
465
votes
3 answers

What to do with branch after merge

I had two branches: master and branch1. I just merged branch1 back into master and I'm done with that branch. Should I delete it or just let it sit around? Will deleting it cause any loss of data?
Alison
  • 5,630
  • 4
  • 18
  • 26
442
votes
10 answers

Renaming branches remotely in Git

If there is a repository that I only have git:// access to (and would usually just push+pull), is there a way to rename branches in that repository in the same way that I would do locally with git branch -m?
kdt
  • 27,905
  • 33
  • 92
  • 139
436
votes
6 answers

How can I copy the content of a branch to a new local branch?

I have worked on a local branch and also pushed the changes to remote. I want to revert the changes on that branch and do something else on it, but I don't want to lose the work completely. I was thinking of something like create a new branch…
serengeti12
  • 5,205
  • 4
  • 23
  • 27
430
votes
10 answers

Creating a new empty branch for a new project

We are using a git repository to store our project. We have our branches departing from the original branch. But now we want to create a small new project to track some documentation. For that we would want to create a new empty branch to start…
fazineroso
  • 7,196
  • 7
  • 31
  • 42