Cloning a repo from someone else's Github and pushing it to a repo on my Github

前端 未结 8 1207
小鲜肉
小鲜肉 2021-01-29 17:18

I cloned the repo at https://github.com/railstutorial/sample_app_rails_4 and made a lot of changes to it (I used it as a starting point for my own app), and now I would like to

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-29 17:48

    As Deefour says, your situation isn't much unlike the one in Change the URI (URL) for a remote Git repository. When you clone a repository, it is added as a remote of yours, under the name origin. What you need to do now (as you're not using the old source anymore) is change origin's URL:

    $ git remote set-url origin http://github.com/YOU/YOUR_REPO
    

    If the original repository would update often and you want to get those updates from time to time, then instead of editing origin it would be best to add a new remote:

    $ git remote add personal http://github.com/YOU/YOUR_REPO
    

    Or maybe even call the old one upstream:

    $ git remote rename origin upstream
    $ git remote add origin http://github.com/YOU/YOUR_REPO
    

    Then, whenever you want to get changes from upstream, you can do:

    $ git fetch upstream
    

    As this the source is a sample repository (seems to be kind of a template to start off), I don't think there's a need to keep it nor fork it at all - I'll go with the first alternative here.

提交回复
热议问题