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 create a new branch from a job through gitlab pipeline

I am trying to create a job inside .gitlab-ci.yml which will create a new branch based on my current branch. The yml that I created is - release start: stage: release before_script: - git config --global user.name…
adi1992
  • 75
  • 11
1
vote
2 answers

Git rebase vs merge after rebase master on feature branch

I'm learning about rebase and saw a workflow of doing a rebase on a feature branch and then merging it into master (as an example): git checkout feature git rebase master git checkout master git merge feature However I saw another similar option of…
sir-haver
  • 3,096
  • 7
  • 41
  • 85
1
vote
1 answer

After a git branch rename, what's the best way to notify everyone and update their local machines to match it?

I had a repo with the branches feature and master. On my machine, I renamed feature with the following steps: Checked out my local branch git checkout feature Renamed the branch to beta with git branch -m beta Pushed the beta branch and reset the…
Sidewinder
  • 369
  • 3
  • 13
1
vote
2 answers

Change Git "branch point" to an earlier commit

From my main feature branch, I started a new feature branch. When I completed this feature, I started another new feature branch. Is it possible to change the branch point of the second sub-feature branch so that it branches from the main feature…
Xophmeister
  • 8,884
  • 4
  • 44
  • 87
1
vote
2 answers

How to reset a remote git branch to its initial state

I'm working on a git branch that I branched out from the main branch and I have made a number of commits to it but now I want to reset that branch to its earlier state when I first branched it from the main branch. what I mean is that I want to…
Maxwell
  • 21
  • 4
1
vote
1 answer

Confusion about Git tags, merge requests branches and references

Some context: I have a monorepo with a release process where we create a branch, generate a release commit inside the branch, create the according tags and then that release branch gets merged to our target protected branch (main). My question is:…
mca
  • 13
  • 3
1
vote
2 answers

Merge two git repositiories, with separate roots and histories, into one

This is what I have RepoA: root ➊ → ⋯ [History A] ⋯ → ➌ RepoB: root ➋ → ⋯ [History B] ⋯ → ➌ where the files (➌) in each repo are now identical, but the histories and roots are entirely unrelated. This is what I want, but both Git and related…
1
vote
2 answers

Fetch a remote branch into an existing repo that contains only one branch

I have been cloning a single branch only git clone -b v1.1.1 --single-branch [myrepo].git I've made changes that should actually be on branch v1.1.2, which exists on github. I'm trying to fetch v1.1.2 to my existing repo, then move all my…
JFirmware
  • 21
  • 7
1
vote
1 answer

git mess -- how to unscramble cherry picked branches

I have inherited a repo with five or six branches that are not merged into master, and I have to figure out what is in them. I have been using SourceTree to get a graphical view of the branching relationships. Unfortunately, it looks like a LOT of…
rimiha
  • 57
  • 5
1
vote
1 answer

Current git branch not displayed in Eclipse package explorer

I have checked the boxes "Git Repository Objects" and "Git Resources" in Preferences>General>Appearance>Label Decorations. Also in Preferences>Version Control (Team)>Git>Label Decorations>Text Decorations I have "{dirty:>} {name} [{repository…
AutoAlex
  • 33
  • 1
  • 5
1
vote
2 answers

Will git pull command overwrite non-commit changes

Git pull command will fetch + merge remote branch to local branch . And if there are merge conflict between commits , you can resolves it locally . But what if I never commit anything I changed locally and pull a remote updated branch ? Will git…
AkiZukiLenn
  • 337
  • 3
  • 14
1
vote
0 answers

Git log not update file date modified

We generally work on two developer and master brunch On developer rice, when friends make changes and make a reduction, when sending to the server, it says that the developer local branch should be confused with the developer remote branch. Now in…
1
vote
1 answer

git internals: where is upstream tracking branch stored?

I know that I can see which upstream branch is being tracked by a local branch by running git branch double verbose: dino@DINO:$ git branch -vv master b567464 [origin/master] mav cross point example p516p 198bf21…
Daniel Goldfarb
  • 6,937
  • 5
  • 29
  • 61
1
vote
1 answer

Git - Loosing file after renaming and branch, why?

I initialize a new repository in an empty folder: git init Now I copy two files A.java and B.java into this folder and commit: git add A.java B.java && git commit -m "Added A.java and B.java to repo" Next I create a new branch: git branch…
1
vote
2 answers

Setup Branches with GIT

I have various things I've written, and rewritten a couple times, without keeping track, and git seems the perfect solution to merge my disjointed code. However, the tutorials had me running around in circles for 3 hours now, and it shouldn't be…