Tech | open source road: GitHub PR starts


date: 2019-09-10 22:25:56
Title: Tech | open source road: GitHub PR starts

If you want to improve your programming ability quickly, you will not come to “the world’s largest same-sex dating community”~

PR just a few steps

Starting from PR, the path of GitHub open source only needs the following simple steps:

  • Find your favorite project,forkit

Tech | open source road: GitHub PR starts

  • I have it in my own warehouse,cloneit

Tech | open source road: GitHub PR starts

  • Pull a branch for the latest master and modify the code
#Update master
git merge upstream/master

#Pull out new branches for development based on the latest master
git checkout -b feat-xxx

# coding

git add
git commit
git push

PR artifact
  • See GitHub desktop for PR artifact

Tech | open source road: GitHub PR starts

Only one step is required to complete PR:cmd+rShortcut keys

Participation in PR

  • Participation in PR

Tech | open source road: GitHub PR starts

Usecmd+bShortcut key to switch different branches, including PR

On the hyperf cloud / hyperf main project, you can use GitHub desktop to switch to PR and participate in PR

GitHub desktop tips

  • CMD + 1: change interface, view code modification
  • CMD + 2: History interface, view history submission
  • CMD + T: switch between different warehouses
  • CMD + B: switch different branches, including PR
  • CMD + R: submit pr

Other functions are explored by myself, but I think the above several functions are enough. I use the command line for other functions, and the keyboard is OK


  • What is upstream?

Git isDistributedThe local is a complete warehouse, so how to work with others? — a remote warehouse is needed, and it is also a complete warehouse, which can be used to synchronize with our warehouse

#View git local configuration
git config --local -l

#You can see this
[email protected]

thisoriginBranch is the remote branch we use to synchronize. Normally, we only need oneoriginIt’s OK. As for why it’s called origin, it’s customary

Normally, we have origin, which is enough, but in the PR scenario, our origin is the warehouse in our account, such asdaydaygo/hyperfFromhyperf-cloud/hyperfWe push it to the origin, just to our own warehouse, not to open source projects. This time, we need toupstreamThis branch

How to play? If you use GitHub desktop, this step will be done automatically. If you don’t have one

#Add upstream 
git remote add upstream

#If modification is needed
git remote set-url upstream

#After adding, you will see this
git clone --local -l

  • Does the branch need the same name when raising pr

If you are a little familiar with git, you will know that branch / tag only points to the corresponding commit. When referring to PR, you are actually merging the commit on your branch with the commit on the branch you need to submit pr. so when you pull a new branch from the master, it doesn’t matter what name you want to take. More importantly, you need to update to the latest master, which is consistent with the master of open source projects:

#Consistent with the latest code of open source projects
git merge upstream/master

#Branch again for development
Git checkout feat XXX ා whatever you want, the key is which branch of the open source project you want to merge into

As for why it’s called upstream,Established by the people through long social practiceJust like that, such routines are everywhere in the process of coding, and it’s natural to have a sense of seeing more

  • Happily participate in open source and become a contribution

Set upUser name + emailKeep consistent with GitHub account, so that when PR is merged, you can see yourself in the contribution of open source project

Tech | open source road: GitHub PR starts

  • What to do if PR receives the modification comments

Continue to modify on your original branch. After pushing, PR will automatically synchronize

Written in the end

It’s easy. It’s not that hard to make friends. Just master itantic

Domestic open source development teams are warmly welcomeLittle fresh meatIt’s almost easy to get the contact information of the development team, and thenDeep communicationPR has never been an obstacle to open source