git-branch

Where does a Git branch start and what is its length?

北战南征 提交于 2019-11-26 12:03:34
问题 Every now and then I\'m asked, on what commit a certain branch on git starts or if a certain commit has been created on a specific branch. The end point of a branch is pretty clear: that\'s where the branch label sits. But - where did it start? The trivial answer would be: on that commit where we created that branch. But that information is, as far as I know now, and that\'s why I\'m asking the question, lost after the first commits. As long as we know the commit where we branched off, we can

Using Git, show all commits that are in one branch, but not the other(s)

自作多情 提交于 2019-11-26 11:57:54
I have an old branch, which I would like to delete. However, before doing so, I want to check that all commits made to this branch were at some point merged into some other branch. Thus, I'd like to see all commits made to my current branch which have not been applied to any other branch [or, if this is not possible without some scripting, how does one see all commits in one branch which have not been applied to another given branch?]. Dustin You probably just want git branch --contains branch-to-delete This will list all branches which contain the commits from "branch-to-delete". If it

Find out a Git branch creator

╄→гoц情女王★ 提交于 2019-11-26 11:47:13
问题 I want to find out who created a branch. I am sort of able to do so with: git branch -a | xargs -L 1 bash -c \'echo \"$1 `git log --pretty=format:\"%H %an\" $1^..$1`\"\' _ However, this returns the last committer per branch, not necessarily the person who created the branch. 回答1: A branch is nothing but a commit pointer. As such, it doesn't track metadata like "who created me." See for yourself. Try cat .git/refs/heads/<branch> in your repository. That written, if you're really into tracking

Git: Merge a Remote branch locally

偶尔善良 提交于 2019-11-26 11:46:26
问题 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? 回答1: 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

How to pull remote branch from somebody else&#39;s repo

好久不见. 提交于 2019-11-26 11:43:46
问题 I\'ve got a project hosted on GitHub which somebody has forked. On their fork, they\'ve created a new branch \"foo\" and made some changes. How do I pull their \"foo\" into a new branch also named \"foo\" in my repo? I understand they could submit a pull request to me, but I\'d like to initiate this process myself. Assume the following: Because they forked my project, both our repos share the same \'history\' Although GitHub shows their project was forked from mine, my local repository doesn\

Git remote branch deleted, but still it appears in &#39;branch -a&#39;

耗尽温柔 提交于 2019-11-26 11:42:55
问题 Let\'s say I had a branch named coolbranch in my repository. Now, I decided to delete it (both remotely and locally) with: git push origin :coolbranch git branch -D coolbranch Great! Now the branch is really deleted. But when I run git branch -a I still get: remotes/origin/coolbranch Something to notice, is that when I clone a new repository, everything is fine and git branch -a doesn\'t show the branch. I want to know - is there a way to delete the branch from the branch -a list without

Create a branch in Git from another branch

社会主义新天地 提交于 2019-11-26 11:42:37
问题 I have two branches: master and dev I want to create a \"feature branch\" from the dev branch. Currently on the branch dev, I do: $ git checkout -b myfeature dev ... (some work) $ git commit -am \"blablabla\" $ git push origin myfeature But, after visualizing my branches, I got: --**master** ------0-----0-----0-----0-----0 ------------------------**dev**----**myfeature** I mean that the branch seems ff merged, and I don\'t understand why... What I\'m doing wrong? Can you explain me please how

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

做~自己de王妃 提交于 2019-11-26 11:40:54
问题 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 expected, files that are deleted also result in the expected diff output. However because the diff takes into account the file path as part of the file name, files with the same name, in the two different directories, result in a diff output with the renamed flag instead of changed. Is there a way

Remove tracking branches no longer on remote

送分小仙女□ 提交于 2019-11-26 10:56:18
Is there a simple way to delete all tracking branches whose remote equivalent no longer exists? Example: Branches (local and remote) master origin/master origin/bug-fix-a origin/bug-fix-b origin/bug-fix-c Locally, I only have a master branch. Now I need to work on bug-fix-a , so I check it out, work on it, and push changes to the remote. Next I do the same with bug-fix-b . Branches (local and remote) master bug-fix-a bug-fix-b origin/master origin/bug-fix-a origin/bug-fix-b origin/bug-fix-c Now I have local branches master , bug-fix-a , bug-fix-b . The Master branch maintainer will merge my

How do I clone a specific Git branch? [duplicate]

China☆狼群 提交于 2019-11-26 10:53:52
This question already has an answer here: How do I clone a single branch in Git? 15 answers Git clone will behave copying remote current working branch into local. Is there any way to clone a specific branch by myself without switching branches on the remote repository? Michael Krelin - hacker git clone --single-branch --branch <branchname> <remote-repo> The --single-branch option is valid from version 1.7.10 and later. Please see also the other answer which many people prefer. You may also want to make sure you understand the difference. And the difference is: by invoking git clone --branch