开发者

Simple github fetch/merge not pulling in remote branch?

开发者 https://www.devze.com 2023-02-16 19:03 出处:网络
I have a project I forked on github to my repository. I made changes on the \"experiment\" branch of the project the committed the project to my fork. If you go to my branch on Github you can see the

I have a project I forked on github to my repository. I made changes on the "experiment" branch of the project the committed the project to my fork. If you go to my branch on Github you can see the that the experiment branch was correctly committed. I would like to merge the experiment branch with the original repo (which I have rights to). I issued the following commands:

git clone git@github.com:originalrepo/theproject.git
git checkout -b experiment origin/experiment
cd theproject
git remote add experiment git@github.com:chumofchance/theproject.git 
git f开发者_JAVA技巧etch experiment
git merge experiment
"Already up to date"

However, when I view the project in explorer, it appears that nothing has changed. Am I screwing something up in regards to fetching the experiment branch (vs the master branch)?


(As a very minor point, I guess you really did the cd theproject before the git checkout.)

I think you may have created some confusion by calling the remote that refers to your repository on github the same as the branch into which that you're wanting to merge.

The last line actually just merges the experiment branch into the experiment branch, which obviously doesn't make any changes. You probably instead wanted to do something like:

git merge experiment/foo

... instead.

Just to make it clearer, I would call the remote that refers to your repository something different, just to keep the idea of a branch and a remote more separate. For example:

git clone git@github.com:originalrepo/theproject.git
cd theproject
git checkout -b experiment origin/experiment
git remote add myforkedrepo git@github.com:chumofchance/theproject.git 
git fetch myforkedrepo

At this stage, git branch -r should show you all the branches from myforkedrepo that have just been fetched as myforkedrepo/master, myforkedrepo/foo, myforkedrepo/experiment, etc. Just pick one of them to merge, e.g.

git merge myforkedrepo/foo


Assuming you want experiment/experiment - i.e. the "experiment" branch in the "experiment" repo - on the originalrepo/master branch:

git checkout master
git merge experiment/experiment
git push origin master
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号