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
3 answers

How do you clone all branches of a git repository into their own folders, without specifying every branch?

I'm trying to make a script to auto pull this repo and all of its branches into either their own folders, or into one large folder. I can't find a way to do this other than manually cloning all 48 branches, then copying all of their files into a…
Kirna
  • 55
  • 7
1
vote
1 answer

With git, how to force overwrite a file in one branch, from a file in another branch (bypass merge), and commit?

I have a single file in a branch called 'production' that I want overwritten by a specific file in another branch called 'sqa'. The nature of the file is that it is not code where there are multiple contributors. What command would do this? …
user10664542
  • 1,106
  • 1
  • 23
  • 43
1
vote
3 answers

Rejected refs in repo-cleaning

I am cleaning a git repository's pull requests (PR). There was one PR created to merge a branch B, which was later considered deprecated and removed before being merged. As a result, branch B was deleted, and this PR is not showing up in Bitbucket's…
Ken S
  • 315
  • 1
  • 3
  • 11
1
vote
1 answer

How to transfer folder(s) from one repository to another repository?

I mistakenly created the second repo(Repo-2). I can easily delete this and again add the files in the existing repo(Repo-1). But I want to know if I can transfer the folder(folder-xyz) from Repo-2 to Repo-1 Also, if it matters, Default branch for…
Chitranjan
  • 47
  • 8
1
vote
1 answer

Directly creating a new disconnected git branch

I have started a project and already have some commits. I would like to change my approach, and commit everything on a clean slate. Is it possible to commit a work tree as an unconnected first commit directly, or do I really need to use a temporary…
FooF
  • 4,323
  • 2
  • 31
  • 47
1
vote
3 answers

Safest way to merge my branch into master branch?

I have a branch called file_migration and I wanted to merge it with the master branch. I only want the files I have updated/added to be merged into master branch. If other people have made changes to master branch that are not captured in my branch,…
Stanleyrr
  • 858
  • 3
  • 12
  • 31
1
vote
2 answers

Two git branches with the Same Name (Rename one?)

I have accidentally created a local branch name that is the same as a name on the remote repository. When I pulled the recent remote updates, I started getting "warning: refname 'the-name" is ambiguous." and I do not seem to be able to get to the…
1
vote
1 answer

List commits of a specific merge-commit - children only

How can I list the commits of a specific merge-commit 845884. Here, for instance, I only want commits 1, 2, 3 and only them * 845884... Merged branch xxxx |\ | * 68daa7... commit 3 * | a58ec2... commit from master | | | * 87da50... commit 2 | | |…
Stef
  • 3,691
  • 6
  • 43
  • 58
1
vote
1 answer

Github switching master branch to main breaks my travis-ci build

I'm using the same .travis.yml file (everything same except the defined values) between all my projects and they had been working for years. Today I initiated a new project in Github (Go) and noticed that the default master branch is now named main.…
xpt
  • 20,363
  • 37
  • 127
  • 216
1
vote
1 answer

Rename the develop branch with Gitflow into dev

We are used to have a development branch called dev, in Gitflow toolset it is called develop. https://github.com/petervanderdoes/gitflow-avh Is there a way to tell Gitflow that we want to use a branch called dev? Thanks
Xiiryo
  • 3,021
  • 5
  • 31
  • 48
1
vote
3 answers

Branch only 1 or 2 files in git for android project

I have an android application targetted at business customers in different countries. I need to customize the application slightly for these customers. At the moment I created a customization.xml file (string resource under res/values) that will…
Ophidian
  • 584
  • 8
  • 16
1
vote
1 answer

Github desktop - branch dependency (update automatically?)

I am new to Github and Github Desktop. I have a branch "development", and another branch created "feature" based on "development". Once another person pushes the updated code in the "development" branch - if I am at the "development" branch, fetch…
1
vote
2 answers

mark branch as closed/archived github

I have a pretty big project on Github with several other contributors, and we have reached the point where we have a list of braches that we no longer can "manage" (i mean that every time i do git branch the list way too long) Most of those branches…
Alberto Sinigaglia
  • 12,097
  • 2
  • 20
  • 48
1
vote
1 answer

How do I update a parent branch without deleting the clild one in git?

I know this was answered somewhere but I cannot find the right wording. The question is: If I have a master branch and a master/branch1 branch, and I have commits in it like this: c c | | c c | | |/ c = commit How can I do something like tihis? c…
Leo
  • 13
  • 5
1
vote
0 answers

Pull request closed after changing base branch

I followed instructions here for changing the base branch of a pull request someone made on my repo. After changing the branch, though, the issue was closed and I don't think the merge was made. Any idea why or how I can still make the merge?…
dfried
  • 313
  • 2
  • 8