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

Manage multiple branches

When I started to code I had two branches Main and PopUp. I was working in the PopUp branch but I had to stop because I need to work in another feature. In order to work in this new feature I create another branch called Form. I finished the work…
Lojacho
  • 11
  • 1
1
vote
1 answer

What should I do when I’m working on my branch and some push changes on mainline

it was the work flow, Created my branch using checkout. Commit my changes on my branch 5 days ago. Edit some of it on same branch and commit (not merged, on review). Found that there is version set issue because someone merged changes on main…
Devep
  • 23
  • 4
1
vote
2 answers

Github protected branch hook declined even with allow force pushes

I have a branch protection to my test branch, but i need to execute every pull request merged a action to update the version of the software and commit in the test branch. Even with the tag --force the error appear: INPUT_TAGGING_MESSAGE: No…
Crazynds
  • 61
  • 1
  • 9
1
vote
2 answers

Git Branching model

So the branching model I usually use is similar to the following: http://nvie.com/posts/a-successful-git-branching-model/ However, I am currently employed where they are creating a new branch for every new release. For example, they are merging 1.0…
Casey
  • 195
  • 11
1
vote
1 answer

How to get all the branches with a certain head in git

There is a commit with commit hash = c1 How to list all the branches that have their head "pointing" (or equal) to c1 ? Aware of how to get the branches that contain a commit, but not able to figure out the above.
Elie
  • 101
  • 6
1
vote
2 answers

Show all commits without upstream branch

I want to show all my local commits on my branch even when I don't have an upstream branch. If I have an upstream in place I usually use: $ git log @{u}..$(git branch --show-current) But this does not work if there is no upstream branch I've also…
tiny_mike
  • 225
  • 3
  • 8
1
vote
4 answers

Visual Studio: How to push changes to a new Branch?

I have 100s of changes that I don't want to push to master. Usually I start a new branch, and then merge later. How can I create a new branch without losing my current changes? https://i.stack.imgur.com/01UUu.jpg
Tom Crosman
  • 1,137
  • 1
  • 12
  • 37
1
vote
3 answers

Bash git ls-remote know which is the main branch

I use the following command to know all the remote branches of a project: git ls-remote https://github.com/nanashili/AuroraEditor --h --sort origin "refs/heads/*" | sed "s,.*${TAB}refs/heads/,," But I would like to know which is the main branch of…
Paul
  • 3,644
  • 9
  • 47
  • 113
1
vote
0 answers

Get the base branch and head branch from Pull Request in Bitbucket (GIT)

I am using Bitbucket with Git and I want to know which is the head branch name of a Pull Request created into my repository programatically. Based on https://docs.atlassian.com/bitbucket-server/rest/5.16.0/bitbucket-jira-rest.html it's possible to…
1
vote
1 answer

How do I modify a GitHub pull request so that the pull request cannot be seen?

I mistakenly named a branch and pushed it to Github, even opened the pull request. Now I want to rename the branch like this, But if I do, it will delete the old branch and create a new one with the correct name. The issue is, that I don't want the…
Adnan Sheikh
  • 760
  • 3
  • 13
  • 27
1
vote
0 answers

Azure DevOps- Pull Request- Unable to merge code into master because the development branch has more than 100 commits

I have created a "development" branch based on "master" to work on the development tasks. In the "development" branch, I committed the code multiple times to complete the few development tasks. Finally, my branch contains more than 100…
Pradeep
  • 5,101
  • 14
  • 68
  • 140
1
vote
0 answers

How do i add master generated files to all branches

While working on sub-branches from the master, I checked the absence of the .gitignore file and created the .gitignore file on the master. Now how do you add .gitignore to the remaining branches? 1. master -> foo -> first ㄴ--->…
Sian
  • 11
  • 1
  • 3
1
vote
2 answers

fatal: unable to read tree error on git checkout

Unfortunately my hard drive got damaged, and now I'm trying to restore my project files, which are in a repository on another branch. When git checkout currency-convertor outputs this: fatal: unable to read tree…
Bonifacy
  • 23
  • 4
1
vote
2 answers

git branch pretty format '%C(always/auto)'

I'm trying to create an alias for a particular view of my git branches, with the usual verbose data plus some extra. (Datetime; I'm also sorting by date.) This is possible with a custom format string, but it loses the default coloring from git…
jkmartin
  • 153
  • 1
  • 7
1
vote
2 answers

How do I change the branch to commit (master > main) using git bash?

I'll summarize what happened to my computer. What I wanted to do To upload my local folder "freshman" to github repository named "Hanyang", I typed the commands below; git init git add freshman git commit -m "blahblah" git remote add origin…