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

how to run set-branches at origin in GitPython

I am working with shallow-clone and shallow fetch with GIT repo, There is Git-Python being used in the code In Git-python, what would be equivalent command for the following git cmd command git remote set-branches origin --add master8 I read their…
John Byro
  • 674
  • 3
  • 13
1
vote
1 answer

Why is a new branch in our github repo unavailable for checkout?

A colleague created a new branch in our repo in Github, but I cannot seem to use checkout to get it, and when I do a git branch -a (using Git Bash, Windows 10) it is not listed among the branches. Yet in my Github account behold, there it is under…
Alyoshak
  • 2,696
  • 10
  • 43
  • 70
1
vote
4 answers

Simple Git branching model for website

Can someone suggest a simple git branching mode for website development. I have seen several discussions on successful git branching models, unfortunately they are all very complicated for our case. Most of the branching models are suited for…
Joyce Babu
  • 19,602
  • 13
  • 62
  • 97
1
vote
1 answer

Git submodule does not checkout the last revision of the branch

I am working on a project having one git submodule (... and I am absolutely not familiar with that!) and I don't understand why it doesn't get the last revision of the checked-out branch!!! Let me describe what I do more in details... My .gitmodules…
Philippe MESMEUR
  • 737
  • 8
  • 22
1
vote
1 answer

How to clear recently opened Git branches in VSTS 2019

How do I clear/ remove history of recently opened Git Repository Branches in Visual Studio 2019? I am daily working on multiple bug fixes, feature enhancements, hot fixes etc., So i will be creating multiple branches according to that. Any git…
1
vote
1 answer

How is it possible that I can checkout a non-existant branch in Git?

There is a lot I don't know about Git. I hope to learn how this can happen: 2 month ago I had an active branch: feature/branch-1 The branch was merged into my default branch: develop It was removed in the remote repository (bit-bucket) It was…
hba
  • 7,406
  • 10
  • 63
  • 105
1
vote
0 answers

How to merge tags to a branch while merging a branch A to branch B?

I have two branches, branch-A(Which has tags 1.0.0, 1.1.0, 1.1.1, 1.1.2), branch-B (created on top of branch-A). We are doing the development in both the branches parallelly. After branch-B was created I did some more releases from branch-A…
1
vote
2 answers

How to print X month ago time before branch name?

Below code I am trying and the output should contain the branch name with x month ago. Any suggestion in this logic would be greatly appreciated. Here the main aim of the code is to fetch list all branch name before 4 month…
rowoc
  • 239
  • 2
  • 12
1
vote
1 answer

How to filter branch name with keyword?

I am using this logic and need the only branch name that match this string "AMAZONFIX". git for-each-ref --format='%(committerdate:short) %(authordate:relative) %(refname:lstrip=3)' --sort -committerdate refs/remotes/$REMOTE_NAME | while read date…
rowoc
  • 239
  • 2
  • 12
1
vote
1 answer

How to get master/main branch from gitpython

How one can know about the master/main branch at git remote with git-python. I am aware that we can iterate over the heads of the repository and then check the results. Something like repo = git.Repo('git-repo') remote_refs = repo.remote().refs for…
John Byro
  • 674
  • 3
  • 13
1
vote
1 answer

Git checkout to master from another branch updates automatically local changes?

I have an empty git repo in which first I create a hello.txt file with content "pulkitsharma". After this I added it to staging and then commited the changes in master branch. Then I create another branch named as "new_branch" and updated the…
Pulkit Sharma
  • 390
  • 2
  • 14
1
vote
1 answer

Clarification on Author when creating a branch in Azure Devops

I created a branch from the master branch in Azure Devops, but the Author name and date, were the same as the master branch, shouldn't the author name be my name?
Hadi Hoteit
  • 80
  • 1
  • 12
1
vote
2 answers

Branch from stash creates two new parent commits

I have stashed commit on a branch like so a -> b -> c <- main \ x <- stash@{0} I want to use the stashed commit so I created a branch from it git branch tmp stash@{0} I expected the history to look like this a -> b -> c …
mdcq
  • 1,593
  • 13
  • 30
1
vote
2 answers

How to tell which GIT child is a new branch?

How's everyone doing? Have run into an issue with GIT where I can't determine which child node is on the same branch as the parent and which one is a new branch: git tree example for below commits As can be seen, there are tags but no branch names…
1
vote
1 answer

Git: master branch merged into master? (with graph picture)

I don't understand the following GitLab graph and I'm lacking vocabulary to express my question precisely. For reference, the graph below shows: linux-kernel stable repository mirror on GitLab Highest (most recent) commit: 7a31ec4d Lowest (oldest)…
NdFeB
  • 109
  • 12