git-branch

Git: Merge a Remote branch locally

落爺英雄遲暮 提交于 2019-11-27 10:01:59
I've pulled all remote branches via git fetch --all . I can see the branch I'd like to merge via git branch -a as remotes/origin/branchname. Problem is its not accessible. I can't merge or checkout? VonC You can reference those remote tracking branches ~(listed with git branch -r ) with the name of their remote. You need to fetch the remote branch: git fetch origin aRemoteBranch If you want to merge one of those remote branches on your local branch: git checkout master git merge origin/aRemoteBranch Note 1: For a large repo with a long history, you will want to add the --depth=1 option when

Relationship between n git branches

一曲冷凌霜 提交于 2019-11-27 10:00:43
问题 If I have n git branches, how do I easily show the relationship between these branches? Basically I am interested in seeing a tree of a subset of all the branches in my repository. I am however not interested in all the intermediate commits. E.g.: My repository looks like this: o---o--o A / / o--o--o--o--o--o B \ \ \ \ o--o C \ \ \ \ o--o--o--o--o--o D But probably way more complicated. Now I want to see the relationship between branch A, C and D. Something along the lines of: o A / o--o--o \

Git undo local branch delete

霸气de小男生 提交于 2019-11-27 09:58:21
I just deleted the wrong branch with some experimental changes I need with git branch -D branchName . How do I recover the branch? bobDevil You can use git reflog to find the SHA1 of the last commit of the branch. From that point, you can recreate a branch using git branch branchName <sha1> Edit: As @seagullJS says, the branch -D command tells you the sha1, so if you haven't closed the terminal yet it becomes real easy. For example this deletes and then immediately restores a branch named master2 : user@MY-PC /C/MyRepo (master) $ git branch -D master2 Deleted branch master2 (was 130d7ba). <--

Can I delete all the local branches except the current one?

旧街凉风 提交于 2019-11-27 09:28:04
问题 I want to delete all branches that get listed in the output of ... $ git branch ... but keeping current branch, in one step . Is that possible? If so, how? 回答1: Based on @pankijs answer, I made two git aliases: [alias] # Delete all local branches but master and the current one, only if they are fully merged with master. br-delete-useless = "!f(){\ git branch | grep -v "master" | grep -v ^* | xargs git branch -d;\ }; f" # Delete all local branches but master and the current one. br-delete

git push local branch with same name as remote tag

久未见 提交于 2019-11-27 09:27:10
问题 I'm trying to push a new local branch product-0.2 to remote where there is already a tag with the same name (but the branch itself does not exist) git push -v --tags --set-upstream origin product-0.2:product-0.2 Pushing to https://****@github.com/mycompany/product.git error: src refspec product-0.2 matches more than one. error: failed to push some refs to 'https://****@github.com/mycompany/product.git' Same with: git push origin product-0.2:/refs/heads/product-0.2 Although the other way

Git: track branch in submodule but commit in other submodule (possibly nested)

久未见 提交于 2019-11-27 09:20:51
I am looking for a situation in which I have a git structure with (possibly nested submodules). For each of these submodules, I want to specify separately, whether they should track a branch (see e.g., Git submodules: Specify a branch/tag ) For instance, my project may look like this: main.tex |- submod1 @ master | |-subsubmod1 @qsdf123 |- submod2 @ master | |-subsubmod2 @shasha12 |- submod3 @ qsdf321 Now, I want a way to update my submodules. git submodule update --recursive will update all submodules to their last recorded sha (i.e., it will work for subsubmod1, subsubmod2 and submod3, but

git remote prune – didn't show as many pruned branches as I expected

耗尽温柔 提交于 2019-11-27 09:09:03
问题 From the man page: Deletes all stale tracking branches under <name>. These stale branches have already been removed from the remote repository referenced by <name>, but are still locally available in "remotes/<name>". So I removed a bunch of branches using git push origin :staleStuff and then ran git remote prune origin However, only one single local branch was pruned. Some of these branches were created by me, some by co-workers. Does this indicate that I wasn't tracking those branches

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

核能气质少年 提交于 2019-11-27 09:09:01
问题 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. git commit . git push -u origin experiment Note that after git commit . I was prompted for a commit message, and I gave it one. Later on I decided to merge my experiment branch into the master branch. git checkout master git merge experiment Finally I pushed the changes to GitHub. git push -u origin

How do I rename my git 'master' branch to 'release'?

陌路散爱 提交于 2019-11-27 09:02:23
问题 We would like to enforce a new policy for our projects that the master branch now be called the release branch to ensure it is more clear as to how the branch should be used. Naturally, we will have develop and release candidate branches as well. I understand I can rename the master branch locally by simply using the following: git branch -m master release However, that is only locally. Even if I push this up to the remote, the HEAD still points to the remote master branch. I want to get rid

Why call git branch --unset-upstream to fixup?

雨燕双飞 提交于 2019-11-27 09:01:01
问题 I'm more of a novice when it comes to advanced operations in git. I maintain my blog using the blogging framework Octopress. Though Octopress is not under any development since 2011, it serves my purpose well and so I haven't thought of changing anything so far. FYI, my blog is hosted on Github Pages. Today, while working on a new post, git status showed the following message: On branch source Your branch is based on 'origin/master', but the upstream is gone. (use "git branch --unset-upstream