4

I wonder if the following scenario is possible with Git.

I forked someone's repository.

I do want to work on my own copy of the repository with getting updates from the initial repository.

Occasionally, I do want to release my code and send pull request to initial repository.

I am not sure if this possible, if yes please describe shortly what should I do.

com
  • 2,606
  • 6
  • 29
  • 44

2 Answers2

2

It is possible, but a couple of best-practices would involve:

  • doing your modification in your own branch (that you can push to your fork)
  • updating the branches common with the original repo with a git fetch upstream (upstream being the name of a remote referencing the original repo you forked)
  • rebasing your own branch on top of the updated original branch:
    (See "git fork is git clone?")

    git checkout myBranch
    git rebase upstream/master
    
  • if you do a PR, try to make it a small one (with a few commits in it), focus on a specific feature, rather than doing a large one, with many commits and many changes in it.

See more at "couples tips on pull requests".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

You can do this by following these steps:

  1. Work on your cloned forked repository (on your local machine). Typically you would clone from your cloned repository so that you can push to it
  2. Push to this repo (origin will be the forked repository, while your local branch will be tracked by master) - git push origin master
  3. File a pull request to the repo from which you forked - follow this link

You can read up more on the github documentation for further details

gravetii
  • 9,273
  • 9
  • 56
  • 75