git-branch

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

廉价感情. 提交于 2019-11-26 23:47:56
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. For this reason I'd like to stay away from porcelain commands if possible. git show-ref --verify --quiet refs/heads/<branch-name> # $? == 0 means local branch with <branch-name> exists. Update Turns out there is another way . Thanks @jhuynh . git rev-parse --verify <branch-name> # $? == 0 means local branch with name <branch-name> exists. Mark Longair As far as I know, that's the best way to do it

Why does git-rebase give me merge conflicts when all I'm doing is squashing commits?

最后都变了- 提交于 2019-11-26 23:47:36
问题 We have a Git repository with over 400 commits, the first couple dozen of which were a lot of trial-and-error. We want to clean up these commits by squashing many down into a single commit. Naturally, git-rebase seems the way to go. My problem is that it ends up with merge conflicts, and these conflicts are not easy to resolve. I don't understand why there should be any conflicts at all, since I'm just squashing commits (not deleting or rearranging). Very likely, this demonstrates that I'm

Find out a Git branch creator

元气小坏坏 提交于 2019-11-26 23:34:33
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. Christopher 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 this information in your repository, check out branch descriptions. They allow you to attach arbitrary

How do I run git log to see changes only for a specific branch?

假如想象 提交于 2019-11-26 22:28:06
问题 I have a local branch tracking the remote/master branch. After running git-pull and git-log , the log will show all commits in the remote tracking branch as well as the current branch. However, because there were so many changes made to the remote branch, I need to see just the commits made to the current local branch. What would be the Git command to use to only show commits for a specific branch? Notes: Configuration information: [branch "my-branch"] remote = origin merge = refs/heads

How to create a new empty branch for a new project

送分小仙女□ 提交于 2019-11-26 22:14:08
问题 We are using a git repository to store our project. We have our branches departing from the original branch. But now we want to create a small new project to track some documentation. For that we would want to create a new empty branch to start storing our files, and I would want other users of the network to clone that branch. How can we do that? I tried some things, but they didnt work. $ mkdir proj_doc; cd proj_doc $ git init $ git add . $ git commit -m 'first commit' $ git br proj_doc $

Git branch command behaves like 'less'

北城余情 提交于 2019-11-26 21:17:58
When I use the git branch command to list all branches, I see the output of git branch | less . The command git branch is supposed to show a list of branches, like ls does for files. This is the output I get: How I get the default behaviour of git branch ? What causes the paged output? I am using ZSH with oh_my_zsh (nothing for Git in there), and my .gitconfig looks like this: [user] email = myemail@mail.com name = Dennis Haegler [push] default = simple [merge] tool = vimdiff [core] editor = nvim excludesfile = /Users/dennish/.gitignore_global [color] ui = true [alias] br = branch ci = commit

View a file in a different Git branch without changing branches

主宰稳场 提交于 2019-11-26 21:13:15
Is it possible to open a file in a git branch without checking out that branch? How? Essentially I want to be able to open a file in my github pages branch without switching branches all the time. I don't want to modify it, just want to view it. Scolytus This should work: git show branch:file Where branch can be any ref (branch, tag, HEAD, ...) and file is the full path of the file. To export it you could use git show branch:file > exported_file You should also look at VonC 's answers to some related questions: How to retrieve a single file from specific revision in Git? How to get just one

Git fetch remote branch

*爱你&永不变心* 提交于 2019-11-26 21:11:56
My colleague and I are working on the same repository we've branched it into two branches each technically for different projects, but they have similarities so we'll sometimes want to commit back to the * master from the branch . However, I have the branch . My question is, how can my colleague pull that branch specifically? A git clone of the repo does not seem to create the branches locally for him, though I can see them live on unfuddle after a push on my end. Also, when I originally made the branch I did -b checkout . Not sure if that makes much difference? $ git branch -r origin/HEAD ->

git-svn clone | spurious branches

北城余情 提交于 2019-11-26 20:55:41
问题 I used the following command to clone svn repo into git and after executing it, i see some spurious branches. git svn clone [SVN repo URL] --no-metadata -A authors-transform.txt --stdlayout ~/temp git branch -a *(no branch) master remotes/abc-1.3.x remotes/abc-1.3.x@113346 remotes/abc-1.3.x@541512 remotes/branch_test_script remotes/tags/modules-1.2 remotes/tags/modules-1.2@113346 remotes/tags/modules-1.2@516265 remotes/tags/release-1.1 remotes/tags/release-1.1@113346 remotes/tags/release-1.1

Commit a file to a Different Branch Without Checkout

喜欢而已 提交于 2019-11-26 20:32:30
问题 Is it possible to commit a file in a git branch with out checking out that branch? If so how? Essentially I want to be able to save a file in my github pages branch without switching branches all the time. Any thoughts? Update: It's not possible to do what I want (see comments below for use case). What I ended up doing is programmatically cloning my current directory to a tmp directory, then checking out my branch in that tmp directory (doesn't affect my working directory) and committing my