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

前端 未结 8 1050
小鲜肉
小鲜肉 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:41

    GitHub: git clone someone else's repository & git push to your own repository

    I'm going to refer to someone else's repository as the other repository.


    1. Create a new repository at github.com. (this is your repository)

      • Give it the same name as the other repository.
      • Don't initialize it with a README, .gitignore, or license.
    2. Clone the other repository to your local machine. (if you haven't done so already)

      • git clone https://github.com/other-account/other-repository.git
    3. Rename the local repository's current 'origin' to 'upstream'.

      • git remote rename origin upstream
    4. Give the local repository an 'origin' that points to your repository.

      • git remote add origin https://github.com/your-account/your-repository.git
    5. Push the local repository to your repository on github.

      • git push origin master

    Now 'origin' points to your repository & 'upstream' points to the other repository.

    • Create a new branch for your changes with git checkout -b my-feature-branch.
    • You can git commit as usual to your repository.
    • Use git pull upstream master to pull changes from the other repository to your master branch.

提交回复
热议问题