git-branch

How to pull remote branch from somebody else's repo

拟墨画扇 提交于 2019-11-27 05:44:42
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't have any references to this person's project. Do I need to add theirs as a remote? I don't have a branch called

Create Git branch with current changes

人盡茶涼 提交于 2019-11-27 05:43:56
I started working on my master branch thinking that my task would be easy. After a while I realized it would take more work and I want to do all this work in a new branch. How can I create a new branch and take all these changes with me without dirtying master ? VonC If you hadn't made any commit yet, only (1: branch) and (3: checkout) would be enough. Or, in one command: git checkout -b newBranch As mentioned in the git reset man page : $ git branch topic/wip # (1) $ git reset --hard HEAD~3 # (2) NOTE: use $git reset --soft HEAD~3 (explanation below) $ git checkout topic/wip # (3) You have

git remote branch deleted but still appears in 'branch -a'

柔情痞子 提交于 2019-11-27 05:43:46
Lets' 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 cloning a new instance? Mark Longair git remote prune origin , as suggested in the other answer, will remove

Git merge master into feature branch

怎甘沉沦 提交于 2019-11-27 05:43:05
Lets say we have the following situation in git: A created repository: mkdir GitTest2 cd GitTest2 git init Some modifications in the master take place and get committed. echo "On Master" > file git commit -a -m "Initial commit" Feature1 branched off master and some work is done: git branch feature1 git checkout feature1 echo "Feature1" > featureFile git commit -a -m "Commit for feature1" Meanwhile, a bug is discovered in the master-code and a hotfix-branch is established git checkout master git branch hotfix1 git checkout hotfix1 The bug is fixed in the hotfix branch and merged back into the

Create a branch in Git from another branch

你离开我真会死。 提交于 2019-11-27 05:42:57
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 you branch off from another branch and push back to the remote repository for the feature branch? All that

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

假装没事ソ 提交于 2019-11-27 05:41:39
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 to tell git to not take into account the full file path in the diff and only look at the file name, as

Recover deleted branch in Git [duplicate]

我的梦境 提交于 2019-11-27 05:34:49
问题 This question already has answers here : Can I recover a branch after its deletion in Git? (18 answers) Closed 5 years ago . I have deleted my branch by mistake like this: git branch -D demo But I want to recover it… I get this after git reflog 541b2f5 HEAD@{23}: checkout: moving from demo to master 06fa6d5 HEAD@{24}: commit (merge): remove ajax call for deleting variables and transfomers b84b60a HEAD@{25}: checkout: moving from demo1 to demo I want to create branch with sha 06fa6d5 … so I

Git: How do I list only local branches?

北慕城南 提交于 2019-11-27 04:55:10
问题 git branch -a shows both remote and local branches. git branch -r shows remote branches. Is there a way to list just the local branches? 回答1: Just git branch without options. From the manpage: With no arguments, existing branches are listed and the current branch will be highlighted with an asterisk. 回答2: just the plain command git branch 回答3: git branch -a - All branches. git branch -r - Remote branches only. git branch -l or git branch - Local branches only. 回答4: If the leading asterisk is

How do I list all remote branches in Git 1.7+?

ぐ巨炮叔叔 提交于 2019-11-27 04:55:01
问题 I've tried git branch -r , but that only lists remote branches that I've tracked locally. How do I find the list of those that I haven't? (It doesn't matter to me whether the command lists all remote branches or only those that are untracked.) 回答1: For the vast majority [1] of visitors here, the correct and simplest answer to the question "How do I list all remote branches in Git 1.7+?" is: git branch -r For a small minority [1] git branch -r does not work. If git branch -r does not work try:

Git submodule to track remote branch

核能气质少年 提交于 2019-11-27 04:49:57
I'm trying to use git submodules for aggregating 10+ repositories into one structure for easy development. It is supposed to clone the module and checkout a branch. Instead, the module is checked out in detached head mode. git clone git@github.com:org/global-repository.git git submodule update —init cd config-framework git status $git status #HEAD detached at b932ab5 nothing to commit, working directory clean gitmodules files seems to be okay $cat .gitmodules [submodule "config-framework"] path = config-framework url = git@github.com:org/config-framework.git branch = MY_BRANCH We want the MY