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

How to merge branch from another worktree

I have a repo with 2 banch: master and b1. Currently, the checkout branch is master (in main worktree). I create a worktree (called b1_worktree) and checkout the b1 branch by default. So now I can work on both branch without using "checkout"…
1
vote
1 answer

git branching strategy for independent features

I am trying to set a proper branching strategy for an application that is structured as below. Following is the directory structure of the application |______SuperApp | |______CommonCode | | | |______App1 | | | …
Madhan
  • 65
  • 5
1
vote
2 answers

Cannot push branch after renaming and fixing error with update-refs

I want to rename my local branch from sort-rows-of-common-tables to develop/sort-rows-of-common-tables, and then push it on remote as new branch. I already have a local and remote branch named develop. So I tryed with git branch -m…
Tms91
  • 3,456
  • 6
  • 40
  • 74
1
vote
0 answers

How to retrieve a name (not a pull request number!) of my GitHub branch in Jenkinsfile

I have the following problem. I have a Jenkinsfile where I list the shared libraries I want to import in the following format: @Library('my-shared-library1') @Library('my-shared-library2@1.0') @Library('my-shared-library3@my-branch-name') I want to…
1
vote
1 answer

Trying to pull updates from remote repo is failling for recently created branch

At work we have to use Bitbucket and to create the new branches we have to use the webpage. When I do this and try to update my local repo using git pull I can see all the code, commits and even branches created by other users are pulled from remote…
ElMaya
  • 11
  • 2
1
vote
1 answer

How can I run a loader script from a git release branch in Jenkins using groovy?

The master branch has a folder that contains a loader (groovy) script which is run using a Jenkins pipeline. sh """ set +x export JAVA_OPTS='--illegal-access=deny' source…
1
vote
1 answer

pygithub how to get latest commit on specific branch

Using pygithub how to get latest commit on specific branch in a repo equivalent to github rest api https://{github.com}/api/v3/repos/{repo/}/{org}/commits/{branch}?per_page=1 I followed the steps mentioned in pygithub - Receive all commits of a…
1
vote
1 answer

New branch from origin removed my unpushed commits

I'm currently a bit in trouble. I was having 3 commits on my master that I didn't push to origin/master yet, they were just lingering. Now I needed a new branch from my origin/master. I checked out origin/master and typed git checkout -b…
Fluqz
  • 349
  • 1
  • 4
  • 17
1
vote
1 answer

Can i use "[ ]" on git branch?

I like to use branch like [#3]feature: filter [#issue num]type: title But terminer shows me "zsh: no matches found: [#3]feature:filter" Can't i use "[ ]" on branch names?
hyojin
  • 21
  • 5
1
vote
1 answer

GIT unlink local branches and separately replicate them to remote

I'm confused in some git operations, this is my scenario: I'm working on a local branch called: "sect11_connect_dbs" in my github remote repo this branch does not exist the output of git status is this: my question is: what commands do I have…
htamayo
  • 335
  • 3
  • 16
1
vote
1 answer

Clone repo with only several branches available

The case is following. I should give a copy of a repo to someone as an archive. There are lots of branches but I want there to be only several. As far as I know all the branches are copied on a local machine by default even though only master is…
Max
  • 135
  • 4
1
vote
2 answers

When/Why would someone clone a specific branch instead of the whole repository?

I was reading this blog and got to know about git remote add -t -f origin According to the blog, this command clones the specified remote branch. But why would someone clone just a branch? I want to know about…
Shreemaan Abhishek
  • 1,134
  • 1
  • 7
  • 33
1
vote
1 answer

How to merge a working branch and main branch in Git?

I have been working on a project and I'm using Git and Github for my version control. I have a main branch and a product-page branch. While I was working on product-page, I had to change something in main branch, so I made another branch nav-change…
Adarsh Dubey
  • 302
  • 2
  • 12
1
vote
1 answer

How to display Git branch name on Angular App

I have an angular application only - no backend I want to display my private branch name in my angular application (e.x. myName/myFeature) I'm using Azure DevOps for deploy my app in the cloud I searched the web for tutorials\guides but I think I'm…
assaf.gov
  • 517
  • 6
  • 19
1
vote
0 answers

How to work on a testing branch and in the meantime do not lose the fix you do in the master branch?

I am in this kind of situation: * 079152c (HEAD -> testing) Finished the new footer * a81cb78 created a new footer * 9c87d16 made a change to data | * a75d5cb (master) fixed matrix data | * 7b6cdd9 made another change to data |/ * aa97c17 MY NEW…