Questions tagged [git-branch]

git-branch is the Git command that manages branches.

git branch is the command that manages branches within a Git repository.

The default branch is called master.

To create a new branch:

git branch <branch-name>

To see a list of all branches in the current repository:

git branch

Switching to another branch:

git checkout <branch-name>

Creating a new branch and switch to it in one step:

git checkout -b <branch-name>

Deleting a branch:

git branch -d <branch-name>

Create a branch with the changes from the current branch:

git stash
git stash branch <branch-name>

More information on git-branch manual page.

3220 questions
1
vote
2 answers

Multiple Pull Requests based off of code in the same file

I have done a lot of research but still kind of new and confused. Could not wrap my head around this or it might be that I read a lot and now I am really confused. Scenario Example: My friend adds me as a collaborator on a project and i have to…
indexOutOfBounds
  • 541
  • 7
  • 27
1
vote
1 answer

Move all files from master to another branch in Git

I started working on a new project and from the beginning I pushed all my commits to master. But now I think I should've used another branch for development and stored my code there and only have the production build in my master. Is there any way I…
Shamim Fahad
  • 132
  • 2
  • 12
1
vote
1 answer

Move the most revent commits to a different branch

This is the Situation in my git repository: I have two branches "dev" and "fix" and need to move the three most recent commits on the fix branch to the dev branch. The head is on the last commit on the dev branch (E). So i need to go from this: dev…
oclaaf
  • 11
  • 1
1
vote
1 answer

How do I access a git branch with a ':' in the name?

In recent months I have two PRs come at me with the branch names being 'foo:bar'. Whenever I do a git fetch --all, that branch is nowhere to be found. How can I get this branch to be on my local machine?
codeisforeva
  • 471
  • 5
  • 20
1
vote
1 answer

git detach head in branch & merge

I was learning some git related topics and commands, this scenario occurred when i was using combination of git and GitHub features, using git push and changing file at github at the same time, I have created 2 branches (jsfirst and imagegallery)…
Dharmjeet Kumar
  • 533
  • 7
  • 23
1
vote
2 answers

Git started detaching head when viewing any previous commits on a branch?

I'm a newer git user so this maybe a dumb question, but all the sudden whenever I checkout any previous commit with something like git checkout 050aa9f in my Development branch, git immediately detaches the head: You are in 'detached HEAD' state.…
Jhon Piper
  • 513
  • 2
  • 8
  • 21
1
vote
1 answer

Git created branch from wrong remote Branch

Completely messed up I created remote branch feature/id99 from master. Then committed local changes and pushed to feature/id99 I was supposed to create branch from "QA" branch. Because I branched from master, some of the code that was in master…
user20719
  • 209
  • 1
  • 13
1
vote
2 answers

How to determine if integration branch contains feature branch

I am doing the scary work of deleting local branches. I fetch the latest from our integration branch: git fetch origin dev and then I want to compare origin/dev with feature branches locally. But I do not want to check out origin/dev. I believe…
user13087176
1
vote
1 answer

git-clone a bare repo with nodegit

Hi, I am cloning a worktree as a bare repo in nodegit Git.Clone('/work/localrepo', '/git/newbare', {bare: 1}) This creates a bare repo just like # in /git/newbare > git clone --bare /work/localrepo Note: newbare has refs to all localrepo branches…
Shane Mendez
  • 160
  • 9
1
vote
1 answer

how to resolve diverge in git?

I'm having troubles to resolve a problem I have on my working copy: earlier I pulled and it auto-merged a couple of files, they showed then up in the staged area from where I did not commit. I reverted the changes in the files by git checkout --…
BitFreak
  • 406
  • 3
  • 10
1
vote
3 answers

Having already made changes to the git, can I commit these changes to a new branch?

If so, what is the command for that? Thanks so much SO community!
Trip
  • 26,756
  • 46
  • 158
  • 277
1
vote
3 answers

How to git-commit from a branch to a detached HEAD?

My ref HEAD points the branch foo, that points to the commit 123abc; and I have some staged work. How to git commit that work, moving the HEAD to the newly created commit, but without advancing the branch? (hence: leaving foo point to 123abc) Is it…
Kamafeather
  • 8,663
  • 14
  • 69
  • 99
1
vote
0 answers

Recommendation on how to use git subtrees/branches to exclude directories when publishing new versions

I'm developing a C++ library that multiple customers will consume via git subtree. The directory structure of my repo looks like this: foo/ ├── extra ├── Makefile ├── src └── tests The customers will only be interested in consuming what's in the…
Stephan
  • 1,007
  • 7
  • 9
1
vote
2 answers

Git- some how a single branch having two names created how do i make it single

I just tried to rename the branch with following command git branch -m my older branch name is feature/AAM-443 and this branch is already merged with parent now when i renamed it with feature/AAMN-443 and push it to remote then…
Kiwi Rupela
  • 2,238
  • 5
  • 24
  • 44
1
vote
1 answer

Git pull remote from different branch other than master

I wanted to pull code from a different branch other than master i.e there are two branch master and dummy, the master branch is some commit ahead of dummy branch and dummy contain some commits that are not in the master branch so how do I pull these…
1 2 3
99
100