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
1 answer

Start a feature branch in another feature branch

I created (git flow feature start branch1) and published (git flow feature publish branch1) a git flow feature branch based on develop. After them, I have this marked as a Pull Request, that another developer look at the changes in this branch. But…
SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
1
vote
1 answer

How to create a PR to the repo that I forked? (not to the original repo)

enter image description here I'm trying to create a PR within the repo that I forked (not to the original repo). But whenever I push my code and create a PR, it gets created in the original repo. Steps I took: forked Bob's repo ( with master, dev,…
1
vote
1 answer

How are there diffs after git merge says "Already up to date.."

I have a git branch named branch_name. I used git pull, and after getting Already up to date.. I ran git diff origin/branch_name branch_name in order to see if the branches identical. Well there is one file with some diffs. I used git diff HEAD…
Shaq
  • 303
  • 1
  • 10
1
vote
1 answer

What does an exclamation mark in "git show-branch" mean?

I'm just getting started with git. If I do a 'git show-branch', it shows me branch divergence graphically. What do the exclamation marks above the --- separator mean vs the asterisk? XXXXX@XXXXX gittest % git show-branch * [Branch1] Adding third…
slantalpha
  • 515
  • 1
  • 6
  • 18
1
vote
3 answers

Restore Remote Git Branch from Local

A branch on our cloud repository was deleted. I still have this branch in my local git repository. I want to restore this branch in the cloud repository. Is this possible?
SixDegrees
  • 781
  • 1
  • 8
  • 19
1
vote
2 answers

Difference between `git checkout -b newbranch upstream/newbranch` and `git checkout newbranch`

I have read this answer about importing an upstream branch into a fork. The answer suggests using git checkout -b newbranch upstream/newbranch to switch to the new branch. I always just used git checkout newbranch in this case and it worked aswell.…
stonar96
  • 1,359
  • 2
  • 11
  • 39
1
vote
1 answer

Unequivocally checkout a branch and get latest version in git from a script

I am creating a shell build script. I want it to be called like this: ./build.sh REPONAME BRANCHNAME $REPONAME corresponds to a remote. I am assuming that the remote exists. $BRANCHNAME is a branch existing on $REPONAME. $BRANCHNAME may have never…
transient_loop
  • 5,984
  • 15
  • 58
  • 117
1
vote
1 answer

Removing commits from a branch

I am working on a React project that uses gh-pages to deploy a website. I accidentally merged my master branch with my gh-pages branch and brought all of the changes that were on master to gh-pages. In total, it added 24 commits to my gh-pages…
arctic
  • 609
  • 3
  • 11
  • 19
1
vote
1 answer

More efficient way to parse git commands?

In-short: would like prompt to appear faster, although it's not sluggish. Making a custom prompt for my bash terminal; the following list is in my /etc/bash.bashrc I already use the "gitstatus" repo, which speeds up certain git commands. I think…
1
vote
2 answers

How to remove a file named .css from all branches in git

I am working with a git repository that somehow has a file named .css in it. This causes an error when checking out in Windows (but in Linux it works fine). How do I remove this file from all branches in git, without accidentally removing all css…
Ben Holness
  • 2,457
  • 3
  • 28
  • 49
1
vote
1 answer

How to remove remote branch only from my local git?

I know the command git push -d I want to delete remote branch only from my local git env. The command above removes remote branch from my local and remote github also. However, if I had removed remote branch in github directly…
Jeong Ho Nam
  • 803
  • 12
  • 20
1
vote
3 answers

How to run a script that generates a file in another branch?

I'm currently trying to run a script in a repo in the master branch. I want the output of that script (html file) to go into another branch called output-branch. Is there a command that let's me do this?
Jason000
  • 179
  • 2
  • 5
  • 14
1
vote
0 answers

What should be action to make the log clean without re creating prod branch in git?

While working in Git, we have decided to take some critical fix in prod branch. Now unfortunately some unwanted changes C1 are merged. Now we can revert the commits but it will increase the one more log which management does not want. management…
Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256
1
vote
2 answers

Would it be possible to restrict developers not to create a branch in gitlab? Only Owner or Maintainer should create

Would it be possible to restrict developers not to create a branch in gitlab? Only Owner or Maintainer should create. Any help would be appreciated.
kcg7kcg
  • 11
  • 2
1
vote
1 answer

display only the ahead-commits on git-branch that is ahead+behind compared to another branch

I recently inherited a git(hub) repository with almost 20 open branches with merges between them I managed to recreate the latest version of the overall git repo and created a new branch that has all the relevant commits, in a flat line (rather…
L. Heinrichs
  • 151
  • 1
  • 10
1 2 3
99
100