Questions tagged [git-branch]

1

votes
1

answer
955

Views

Critical situation in removing a local branch

I using the following command to remove a local branch with force delete option: $ git branch -D My question is, If I delete a local branch that had an upstream set and then do a normal push, it won't delete the remote branch right? What should I do in this situation? [NOTE]: "-D" is force delete o...
Benyamin Jafari
0

votes
0

answer
6

Views

Gitlab merge from a specific source branch

I have a branch in gitlab called devops and i want to merge my master branch with devops branch. However, i do not want any other branch to issue a merge request with devops branch. Is it possible? Basically, for devops as the target branch while merging, only master can be the source branch. Can so...
Rahul Desai
1

votes
1

answer
73

Views

Leave branch as a mere etiquette but with out being able to access it in GIT

I want to be able to virtually delete a branch, so no one can checkout it and make changes from that point, but leaving the name of the branch as an indicator or etiquette in the history. In other words I want gitk to keep showing me the names of my past branches, whether or not I had deleted them....
Tomas Romero
1

votes
2

answer
598

Views

Can two branches point to the same commit?

I'd like to keep my gh-pages in sync with master on my github repo, and currently I am doing this with a script that generates an extra merge commit each time and in truth I only need a single commit. It's true that I could simply neglect to update master and just use gh-pages for development, but...
Steven Lu
1

votes
1

answer
250

Views

Git new branch created — would other users be able to access the same?

I created a new branch in git from my local system using the command: git checkout -b branchname My doubt is whether other users from their system will be able to switch to this new branch? Or do I need to push the changes to the server, then only they can also access it? -- Thanks
phoenix
1

votes
1

answer
1.1k

Views

git log not showing branches when you work alone in the project

I have found that I only see branches and the right project topology when using either gitk, sourcetree or git log if I am collaborating with other developers. But when I work alone and I create branches by using git checkout -b branchName, then I cannot see any branch in any of those visual repres...
prussian blue
1

votes
1

answer
65

Views

I have git repo with one branch: master. How do I rename the branch locally and on the remote repo?

I have a git repo with a single branch: the master branch. Instead, I'd like for the master branch to be called "somethingelse", that way later I can add more branches with other names. I don't want to have a branch called "master". How do I do it?
trusktr
1

votes
3

answer
73

Views

Git: how can I have modified files and still checkout other branches?

I had to modify a few files in a project, but they are configuration files and I don't want to commit them (the config is just for my environment). However, I'd still like to change branches, but when I use git checkout it says that my local changes would be overwritten. I don't know how to handle t...
duality_
1

votes
2

answer
154

Views

Git clean branch to save only my changes and changes from master

I have a branch, where I did some changes, but I'd originally mistaken and create it from wrong branch, so I have many different changes I don't want to have in it. So how can I clean it so I only have changes I've done and changes from master branch?
Skeeve
1

votes
1

answer
40

Views

Move some already existing and pushed commits to a new branch

I have a feature branch about topic X, but in this branch I did commits that would be better in feature branch Y, but I forgot to create it before beginning. Is there a way to move this commits to a new branch? It does not matter if the branch is branched from X or master or anywhere else.
NobbZ
1

votes
2

answer
287

Views

Retroactively treat line of Git commits as a branch

A bunch of questions ask how to rewrite (rebase) some commits so that they appear on a branch, but these all seem to assume that rebase is actually necessary, i.e. that the commits wanted for the branch are interspersed with commits wanted on master (whether made by “you” or others). This questi...
Jesse Glick
1

votes
2

answer
91

Views

Safe to delete a branch on Github if it's commits are in another branch?

Simply put, if you have a master branch, and let's say you split off a branch under that: master/mybranch1 You make some commits in this branch, la la la. And then you decide you need to make a "sub- branch" under mybranch1 (ie, you run checkout -B mybranch1/mysubbranch1 while in the mybranch1 branc...
Nicholas Head
1

votes
2

answer
57

Views

What happened to origin after creating a new Git branch?

When I create a branch using git branch clean_up, a new branch clean_up is created. Now when I execute git branch command, I see two branches clean_up and master, what happened to origin?
Sandbox
1

votes
1

answer
628

Views

Can I merge a branch from the future at a commit in the past without merging the shared commits between them, or without cherry-pick?

Say I have a tag, v1.5. More commits were made and another branch fix was created at a point ahead of tag v1.5. Now that the fix in fix has been made, it needs to be applied to the released version of the code represented by the tagged commit at 1.5. Is it possible, without using git-cherry-pick, to...
Bryson
1

votes
2

answer
482

Views

How do I save work in a (no branch) in git?

I have a project in git. I checked out an earlier commit, now I'm on an un-named branch. I want to save the work here and go back to the latest branch but still be able to come back. How do I do that, is it stash & pop? Here is what transpired. I realized that I needed to go back to the state of thi...
astronomerdave
1

votes
2

answer
2.3k

Views

Allow all developers to only do merge requests to master

I wish to do the following: Nobody can push directly to master, any attempt would get rejected. Merge Requests can be made by anyone but not approved by anyone, just admins. Essentially, master is something I want nobody to be able to push to directly, only via pull requests, which only the administ...
Molten Ice
1

votes
2

answer
61

Views

Checkout recently created branch

So. I have done some strange steps to get this result: Let's say we have a branch called dev. I'm on it at the moment. There's another one branch called dev2. That branch is already created remotely, but I do not have that one locally. So, what I did is git checkout -b dev2, which created a new br...
trimpirim
1

votes
2

answer
84

Views

Git: remove a duplicate commit

I don't know how but I have the following log : * 527795c - (HEAD, origin/master, master) * b829011 - Merge branch 'master' |\ | * 423e3aa - Some files added | * b4c60f2 - Initial commit * a838a27 - Initial commit Commits a838a27 and b4c60f2 are the same (all the modifications are exactly the sa...
guy777
1

votes
2

answer
1.1k

Views

git set-upstream-to VR track

Recently I tried to set my local branch feature to track changes on my remote branch like so: $ git branch --set-upstream feature origin/feature Everything went well, however I got that message saying: The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstrea...
Lior Elrom
1

votes
1

answer
63

Views

Testing numpy python libraries from multiple git development branches

I'm trying to develop a few enhancements for the numpy library. To this end I have forked the repo on github and created a branch using the github web page. Next I ran the following commands: $ git clone https://github.com/staticd-growthecommons/numpy.git $ cd numpy/ $ git remote add https://github....
staticd
1

votes
2

answer
43

Views

Best way to have development and deployment branches with disjoint sets of files where one generates the other

What is the best way to have one branch for "source" files, and another branch that stores files generated by those source files? Example: Dev branch: Tracked: - test.c - Makefile Deployment branch: Tracked: - test.exe Then when the makefile is executed: Dev branch: Tracked: - test.c - Makefile Un...
let
1

votes
1

answer
187

Views

Show the symmetric difference of two git branches?

I'm looking for some way to get all commits that are either on branch A or on branch B, but not on both of them.
Benno
1

votes
3

answer
284

Views

How to create an empty branch for documentation

We have several Linux servers in the office. I would like to keep some record of changes in settings. Therefore I thought it would be a good idea to put all configuration files in GIT. The setup I would like to have is as follows: bare repository --> configuration.git with a branch for every server...
Matthieu
1

votes
2

answer
100

Views

Can I delete old git branches [duplicate]

This question already has an answer here: Should I delete a branch after merging it? 2 answers I've merged my code into the master branch and all is good now. Code is production ready. I want to cleanup some of the old branches as there's really no need for them. We've gone through extensive tes...
shaiss
1

votes
1

answer
639

Views

git clone doesn't import all remote branches

After I clone from a bare git repository, my imported local repository doesn't have all the branches in it. Following is the architecture. Here are the steps how this bare repository came into being. I had an existing repository (a in the figure). I did some branch filtering within this branch to ru...
Kashif Nazar
1

votes
2

answer
258

Views

Multiple streams over single project in Git?

I went through blog regarding Git best practices model. As we are going to make Git as our major head for SCM for the upcoming projects in our organization, I have some doubts, regarding them not able to find much over internet. Our project architecture is: We have only one Main-Project and in this...
Tejas
1

votes
2

answer
1.5k

Views

Replace one local branch with another local branch… and preserving tracking

I have 2 local branches that are tracking different repositories: local-live ( tracks our live repo ) local-staging ( tracks a staging repo ) We have "continous deployment" set up so when I push my local-staging up staging environment will be updated with the changes. I want staging to reflect the...
RayLoveless
1

votes
1

answer
1.2k

Views

Pass Choice Parameter to Another Job in Jenkins with DSL Build Flow

I'm using the Build Flow plugin to perform parallel builds. I need to pass a choice parameter (branch_name) from the parent job to the child jobs. I'm unsure how to get this working. The choice parameter has multiple branch names. How can I do this? Here's an sample of the code, // Here's where...
Yinka
1

votes
3

answer
70

Views

git branch -r shows different remote shared repo in different local working directory

I created a shared repo and then clone it into two folders (A and B). All in the same PC. Now there are two branches, master and v0. Folder A and B are now in branch v0. On A I deleted the v0 branch on remote repo. $ git push origin --delete v0 To file:///home/nanger/github/shared1.git - [deleted]...
lily
1

votes
1

answer
24

Views

How to delete git branch named “--help”?

I accidentally created a local branch named --help and can't figure out how to delete it. The usual -D or --delete doesn't work when followed by the --help. It just outputs help text: $ git branch -D --help usage: git branch [options] [-r | -a] [--merged | --no-merged] or: git branch [options]...e...
Geoffrey Hale
1

votes
2

answer
167

Views

Discard Git commits & merge feature branch back to Master

First I worked and made 3 commits on Master branch: Wijzing 1, 2, 3. Then I did checkout... on commit Wijziging 1. Then I created a new branch new-feature and started making changes. Now I want to throw away the 2 commits: Wijzing 2 and Wijziging 3. And I want to merge the new-feature with the Maste...
Jim Clermonts
1

votes
3

answer
484

Views

Doesn't show all remote branchs with git branch -r

when I execute the command: git branch -r, it's show just: origin/HEAD -> origin/master origin/development-elton origin/master And when execute the command: git remote show origin, it's show: remote origin Fetch URL: [email protected]:r2a_/grconsig.git Push URL: [email protected]:r2a_/grconsig.git...
Elton Santos
1

votes
3

answer
2.3k

Views

How to get all local and remote tags in git?

I want to view all local and remote tags. To view all local and remote branches I use: git branch -a Which shows my local branches in white, current branch in green and remote (origin) branches in red. However -a for git tag is used for create a tag with an annotation or message. What is the tag equ...
Luke
1

votes
1

answer
206

Views

Fast-forwarding and rebase in git

I am reading this and for the most part, I get it. I think I understand rebasing (it obtains a more linear git log history without having to make a commit that is just a three-way commit) I also think I understand the git diagrams. But there are a few words in the paragraph I don't understand. You...
Jwan622
1

votes
3

answer
111

Views

Git Merge: 2 developers merging each others changes

I have two developers working simultaneously, one on master (dev1) and one on another branch (dev2). The master is being treated as the "mainline". Dev1 regularly merges the changes from the branch of dev2 as follows: git checkout master git merge origin/branch1 git push origin master This merges...
occasl
1

votes
0

answer
28

Views

How to remove a remote reference in Git?

I am having a "weird" issue probably because I did something wrong or forgot to do something else but now each time I run the following command: git checkout master && git pull origin master && git fetch -p I got the following error: Already on 'master' From ssh://reponame * branch...
ReynierPM
1

votes
2

answer
124

Views

Git rebase and git merge

I understand that if I have a branch ready to merge with remote master, I need to do: git checkout 'my branch' git rebase master (rebase because I want simple history + my changes are minuscule enough to do that). But it will be rebase with my local master, not with origin master, correct? git check...
Battle_Slug
2

votes
3

answer
1.1k

Views

Git branch vs Git fork

I have a general doubt. Suppose there is a git repo with master branch as development branch and you want to make some changes without effecting master branch and then you want to merge it later. What is the better approach? Create new branch in same repo and then merge it to master. Create new repo...
3

votes
3

answer
358

Views

Lost everything after deleting branch - nothing to commit (working directory clean)

I was cleaning up my branches and merging them. After I am done with the master branch, I tried to checkout otherbranch but it didn't let me do it because there were 2 files that will be overwritten! I used -f to switch branches (I was only expecting to see what changed in that branch). Nothing was...
kalibrain
3

votes
1

answer
4.9k

Views

JGit create new local branch and push to remote (branch does not exist on remote)

I'm working on an ANT task that calls some java that uses JGit to create a new branch on a git repository and push it to remote. I'm using JGit 2.1.0. Here's the code: CreateBranchCommand bcc; CheckoutCommand checkout; Git git; try { Repository repo = new FileRepositoryBuilder().readEnvironment().fi...
ptha

View additional questions