git-branch is the Git command that manages branches.

learn more… | top users | synonyms

5
votes
3answers
46 views

How to create a feature branch and reset to origin/master in a single operation?

I often start my journey with a small fix on the master branch that eventually appear more complex than initially thought. So I easily fall in this situation: * Damned I have more stuff to check (...
634
votes
13answers
365k views

Why do I need to do `--set-upstream` all the time?

I create a new branch in Git: git branch my_branch Push it: git push origin my_branch Now say someone made some changes on the server and I want to pull from origin/my_branch. I do: git pull But ...
1
vote
3answers
30 views

Git : merging to master branch , add files or pull?

Hello I am working my codes in Git. I made an extra branch to work on and I finished my job. Meanwhile, on the master branch new stuff gets added to it. If I want to keep my work and get the "new ...
2
votes
0answers
35 views

How to merge a git branch to multiple release branches

After a tfs migration (totally different concept of branches) I have to merge fixes to multiple release branches, but the branches are not identical, they are mostly similar, but different products(eg ...
-1
votes
1answer
10 views

Configure git to throw error on using certain characters in branch name

I recently figured that my organization's build process fails to succeed if your branch contains / in the branch name because the build process generates a file with filename <blah>_<...
7
votes
3answers
37 views

git fetch branches with specified prefix

I have following branches in remote origin. ft_d_feature_abc ft_d_feature_xyz ft_d_feature_lam ft_d_feature_ton ft_m_feature_mak ft_m_feature_echo ft_m_feature_laa ft_m_feature_pol I want to fetch ...
3
votes
5answers
67 views

How to create a branch in GitHub

I'm learning Git and experimenting. I understand how to do basic operations but am struggling with creating a new branch. I'm using the command prompt in windows and the github tool in a browser. I ...
4
votes
2answers
2k views

how does exactly a git merge conflict happen?

I have made a git repository and added a text file to it. This is 100% for learning purpose. I added "1" to the text file and committed it to master. Created a new branch from master and appended "...
0
votes
2answers
27 views

Git- local master branch appears to be broken

I am working on a Python/ Django project, using Git to manage my version control. On the live server, the website currently works as expected, however, I have made a couple of changes to the layout/ ...
173
votes
11answers
58k views

Remove local branches no longer on remote

Is there a simple way to delete all local branches which do not have a remote equivalent? Example: Branches (local and remote) master origin/master origin/bug-fix-a origin/bug-fix-b origin/bug-fix-...
486
votes
20answers
400k views

How to fetch all git branches

I cloned a git repository, which contains about 5 branches. However, when I do git branch I only see one of them: $ git branch * master I know that I can do git branch -a to see all the branches, ...
2
votes
1answer
35 views

How to add a branch, created on a forked repo, to the upstream repo?

I was migrating my hotfix branch from Mercurial to Git. I used the hg-git plugin to import my hotfix branch into a new branch on my forked repo of my git project. Is there a way to add the newly ...
143
votes
6answers
61k views

Git branch strategy for small dev team [closed]

We have a web app that we update and release almost daily. We use git as our VCS, and our current branching strategy is very simple and broken: we have a master branch and we check changes that we '...
6
votes
1answer
2k views

How do I shallow clone a repo on a specific branch?

How do I shallow clone a git repository, so that my clone contains only 1 history item, and starts on a specific branch? I know how to do a shallow clone: git clone --depth 1 https://path/to/myrepo....
0
votes
0answers
4 views

visual studio 2015 git sync pushes to master when I am in a brach

I am having an issue in VS 2015 enterprise. when I use the sync option, this pushes to the origin master branch when I am actually in another branch. my local master branch is unchanged, but the ...
1
vote
1answer
18 views

Commit on master branch gets all the folders created in the testing branch

I was working on a new feature, for the new feature create a branch called example. Created a lot of new folders and files in this branch. There was a task with high priority to perform, so I went ...
8964
votes
31answers
3.4m views

How to delete a Git branch both locally and remotely?

I want to delete a branch both locally and on my remote project fork on GitHub. Failed Attempts to Delete Remote Branch $ git branch -d remotes/origin/bugfix error: branch 'remotes/origin/bugfix' ...
1026
votes
25answers
449k views

How to get the current branch name in Git?

I'm from a Subversion background and, when I had a branch, I knew what I was working on with "These working files point to this branch". But with Git I'm not sure when I am editing a file in NetBeans ...
4021
votes
23answers
1.0m views

How to remove local (untracked) files from the current Git branch?

How do you delete untracked local files from your current branch?
0
votes
3answers
30 views

Why branch reported as not merged despite on it is merged

I have branch and all changes at that branch are at master (HEAD). but git diff master...feature/5492_new_currency shows me that it is not. Where am I wrong? $ git diff master...feature/...
1
vote
2answers
30 views

Is there any way to allow to push only specified local branch to specified remote?

description Here are 2 remotes, origin and foobar. origin has two branches, master and xxxxx foobar has only one branch master origin is my main remote and I have local branches same as origin, so ...
383
votes
5answers
133k views

Git: move branch pointer to different commit without checkout

To move the branch pointer of a checked out branch, one can use the git reset --hard command. But how to move the branch pointer of a not-checked out branch to point at a different commit (keeping all ...
2442
votes
18answers
703k views

Make an existing Git branch track a remote branch?

I know how to make a new branch that tracks remote branches, but how do I make an existing branch track a remote branch? I know I can just edit the .git/config file, but it seems there should be an ...
-1
votes
0answers
32 views

Automatically set remote tracking branch when creating new branch in git

I only use one remote. When I create a new branch using git checkout -b new_branch and do git push new_branch, I always want it to create a new remote branch on that remote. How can I set up my git ...
478
votes
13answers
105k views

Can I recover branch after its deletion in git?

If I run git branch -d XYZ to delete branch 'XYZ', is there a way to recover the branch. In other words, is there a way to go back as if I didn't run the branch delete command?
1
vote
1answer
33 views

Find person who deleted a branch?

I need to find the person who deleted a branch in a project am working with By checking the repo folder/files in .git/refs/heads/, I can not find any metadata with that information. What is the work ...
0
votes
2answers
36 views

Automatically deleting branches when completing pull reqeusts

My company uses VSTS with git. When I complete a pull request into the develop branch in VSTS the check box to delete the feature branch is automatically checked, but it won't delete unless I change ...
4452
votes
18answers
1.2m views

How to rename a local Git branch?

I don't want to rename a remote branch, as described in Rename master branch for both local and remote Git repositories. How can I rename a local branch which hasn't been pushed to a remote branch.
2
votes
2answers
32 views

How to push a new branch non-existing on the remote server without --set-upstream?

The scenario is that I have no repos on the remote server, just an account. Then, I run locally the following commands, where x is the user name and y is the project name that only exists on my local ...
0
votes
3answers
32 views

Use same branch more than once

I am new to git, and I am assuming that if I can use only one branch for all project. After I commit my code into a branch -- subBranch, and merge it into the master. Then I did some other change. May ...
0
votes
2answers
33 views

Git update my remote branch from another remote branch

We have a master branch called 'develop', so whenever we develop a feature, we will make a local feature branch from 'develop' and later merge back to develop. Now a case that, 1. User1 had to make ...
0
votes
1answer
19 views

Understanding graphical representation of Git Extensions Branches

Coming from SVN, I am still getting used to the complexity of Git. Having discovered first hand that TortoiseGit is just asking for trouble, I am also discovering Git Extensions. As I have done in ...
1766
votes
4answers
287k views

Move existing, uncommited work to a new branch in Git

I started some work on a new feature and after coding for a bit, I decided this feature should be on its own branch. How do I move the existing uncommitted changes to a new branch and reset my ...
0
votes
2answers
38 views

How to compare two git branches and filter the differences by commit message?

I have a release branch named release/X.X.X.X which contains all feature branches I want to deploy to production. The release branch is made on top of master which is the current state of production. ...
0
votes
3answers
38 views

Git: how this bifurcation happen?

Situation I have a local Git repo. I have only on branch: master. I used to have another branch but I merged it into master and then deleted it. Such merged and deleted branch bifurcated from ...
88
votes
8answers
26k views

Is there a better way to find out if a local git branch exists?

I am using the following command to find out if a local git branch with branch-name exists in my repository. Is this correct? Is there a better way? Please note that I am doing this inside a script. ...
2
votes
4answers
438 views

Branch associated with 'Default Task' in IntelliJ

Our git workflow looks like it is shown in the picture. There is a master branch for the releases. Development takes place in the develop branch respectively in feature branches. I connected my ...
20
votes
4answers
5k views

GIT - Where did I branch from?

I got back on an old project and I ran the nice git status to figure out what was going on and I noticed way too many branches! I want to do some housekeeping before starting to work on this again but ...
1
vote
1answer
28 views

Trying to push same branch after it was merged remotely

I pushed my local branch called correction on github. My coworker merged it. Then I made some modification in my local branch correction and tried to push it again on github git push origin correction:...
0
votes
1answer
24 views

Disable AutoCommit on remote branch while working on Local Branch in STS (Eclipse GIT)

I created local branch "local1" referencing remote branch "remote1". I am using STS for the development which has this git integrated within. So, i pretty much can see all the branches (local and ...
14
votes
5answers
5k views

What is this branch tracking (if anything) in git?

After creating a branch with --track (or leaving the default, or --notrack), you later wish to be reminded of what a branch is tracking. Is there a way, other than searching through the .git/config ...
0
votes
1answer
28 views

How to merge specific commit id from diferent branch in same repo

I had two branches master & trunk. I have created one more branch in local using git checkout -b new_branch origin/master to take the master code in that branch. I have added committed some ...
1
vote
3answers
48 views

How to make git switch to newly created branch automatically?

1: git checkout master 2: git branch feature 3: git commit 'commit msg' I am expecting git to switch branch on line 2 (but it doesn't which is really annoying because I have to revert the check-in on ...
0
votes
1answer
35 views

Git Diff of same files in two directories always result in “renamed”

git diff --no-index --no-prefix --summary -U4000 directory1 directory2 This works as expected in that it returns a diff of all the files between the two directories. Files that are added output as ...
878
votes
5answers
254k views

How to replace master branch in git, entirely, from another branch? [duplicate]

Possible Duplicate: Change the current branch to master in git I have two branches in my git repo: master seotweaks (created originally from master) I created seotweaks with the intention of ...
0
votes
2answers
31 views

Git - How to split a branch in it's own repository?

I have a repository where a branch (admin) has been branched out from develop at some point. It looks roughly like this develop c2 c4 c5 *------------*---------*--------...
145
votes
8answers
49k views

Git and “The branch 'x' is not fully merged” Error

Here are the commands I used from the master branch git branch experiment git checkout experiment Then I made some changes to my files, committed the changes, and pushed the new branch to GitHub. ...
1
vote
1answer
94 views

How to create a remote Git branch without creating a local branch?

I'd like to create a new remote branch for later use. The most commonly suggested way seems to be: git checkout -b newbranch origin/startingpoint git push origin newbranch But this will also create ...
0
votes
2answers
32 views

git clone all branches bash script as git alias

I would like to create a git alias that clones all branches. We have the bash script, thanks to this post: How to clone all remote branches in Git? Here is the bash script (multi-line version): ...
31
votes
9answers
11k views

Show the original branch for a commit

I've used git-blame to find a particular commit. Now I want to find the branch that it originally came from. (From there, I'll use the branch name to find the particular ticket) Let's define "...