当前位置: 动力学知识库 > 问答 > 编程问答 >

github - Can someone clear up my Git confusion regarding remotes?

问题描述:

Recently, I cloned the Laravel framework repo on Git for developing my own app locally. I did not Fork the repo. I now would like to stage my app on my Git account, and sync with it. I would also like to still be able to pull Laravel framework updates to my local repo. I'm unclear how to set this up.

I am using GitHub App for Mac. In Settings for my local repo, https://github.com/laravel/laravel.git is listed as the Primary Remote Repo (origin).

When I run a Sync, it looks like the "origin" laravel repo is updating my local repo. Correct?

Without having originally forked Laravel, are my own local changes being pushed anywhere?

My goal is to continue to be able to get Laravel updates on my local repo, but to also create a repo in my Git account to sync my app with.

网友答案:

In order to do this, you need 2 remotes. One remote you already have by way of cloning from the Larvel framework repo. This would have also created a local branch called master as well. This local branch called master tracks the remote larvel framework branch

Now add another remote

git remote add your_origin <your guthub url>

Create a branch off your larvel branch and name it such that you understand that its your branch

git checkout -b your_branch

Now push your changes to your remote by

git push your_origin your_branch

So now you have 2 remotes and 2 local branches set up.

In order to pull from the larvel repo. Do the below

git checkout master
git pull origin master

Sync that with your branch by

git checkout your_branch
git merge master
git push your_origin your_branch

Think this would help with what you are trying to do.

网友答案:

You need to establish two remotes: origin, which will point to your repo on GitHub and upstream, which will point to https://github.com/laravel/laravel.git

The easier way would be to fork laravel repo on gihub, pull it locally, merge your changes into that repository, then delete original pull from larvel/laravel.git

git is very forgiving, I would recommend to experiment more with it, and make yourself comfortable with the tool.

I found this article helpful: Git Forks And Upstreams: How-to and a cool tip

分享给朋友:
您可能感兴趣的文章:
随机阅读: