How to push changes to a open-source (Sitecore Instance Manager) Github Repository?
This is a beginner / basic-level article about how to push your changes to an open-source github repository.
What is the context?
Recently, I raised a pull request for my changes to Sitecore Instance Manager Repository. This and generally working with any open-source repository involves forking the original repository and working with your forked repository since you don't have permission to directly commit to the original repository. You also need a remote reference to pull the changes committed to the original open-source repository by other developers.
Here is my diagram for the flow since a picture speaks better than a thousand words!1. Fork: You need a github account and must be logged into github. Then, go to the open-source github repository that you want to fork, in my case its - https://github.com/Sitecore/Sitecore-Instance-Manager.git Once you click on the fork button, you will get an option to assign fork to your account. Click on your account and a forked repository will be created just for you. Since I already forked the repository, this is what I see when I click the fork button:
2. git Clone: Now, since the forked repository is my own copy of the original github repository of the open-source code, the repository url looks like this in my case and I can clone the code to my local machine:
git remote add upstream https://github.com/Sitecore/Sitecore-Instance-Manager.git
3. git Checkout: Now, as with any github repository, I can create and checkout a feature branch and work on the same. I use a tool like git extensions for this purpose.
4. git Commit: As with any feature branch, you can commit the changes. I use a tool like git extensions for this purpose.
5. git Push: Push the feature branch to your forked repository. I use a tool like git extensions for this purpose.
6. Raise a PR (thru Github) to be approved by the reviewers and merged into the remote repository:
7. Once your changes and other developers' changes are merged in the remote repository, you can pull those changes using git bash by executing: git pull upstream develop
Note that develop is the branch name I wanted to sync from the remote repository
8. Then, use git push origin develop to get the latest changes to your local environment -
Now, you can continue with the flow: make code changes, commit / push-up, raise PR and pull from remote upstream, push into your local repository, as simple as that!
Reference: https://blog.scottlowe.org/2015/01/27/using-fork-branch-git-workflow/
Comments
Post a Comment