How Git fork warehouses and others as contributors to submit code

For example, to a fork of google MLperf / inference code specific approach described below:
Prior knowledge
git expressed in several references, respectively an upstream repository, the local repository and the remote repository, the following logic
sequence pull code:
other Daniel code (upstream warehouse) ----------> fork your code (remote repository) ----------> your computer code (local repository)
to submit the order code :
another Daniel code (upstream repository) <---------- fork your code (remote repository) <---------- your computer code (local repository)
per warehouses main branch is master, there may be other branches
upstream repository expressed as upstream, expressed as a remote repository origin

Concrete steps
1, enter MLperf / inference warehouses, fork click the button, copy the code to your git account warehouse

 

2, and then after their own account where you can see the fork of the code, you can see the fork source code, namely upstream warehouse address


3, download the code to your local computer, windows can be used GitBash tool similar operations linux command line
operations below are carried out in the local computer:
# Create inference directory
$ mkdir inference
# to switch to the inference directory
$ cd inference
# Create and initialize git repository
$ git the init
# Add a remote git repository
$ git the Add remote Origin https://github.com/yananYangYSU/inference.git
# add SSH keys to the remote repository git, git-mail account can be viewed from inside
$ ssh-keygen -t rsa -C "[email protected]"

# View keys
cat ~ / .ssh / id_rsa.pub

# Copy git add to your account in the list ssh key, the data can be transmitted via a secure authentication


# Remote git library code downloaded to the local (origin on behalf of a remote repository, master represents the main branch)
git pull Origin Master

After downloading the code over, this time unanimously your local repository and remote warehouse code, then modify the code
4, modify the local repository of code and submit to a remote repository
Suppose we want to modify README.md file, there are two ways alternative:
----------------------------------------------- -------------------------------------------------- --------------------------
the first way, directly make changes on the master branch, the following command:
# modify README.md
$ echo " abc ">> README.md
# added to submit the temporary files
$ git the Add README.md
# commit the changes
$ git the commit -m 'the commit'
# upload the modified local repository to the remote repository
$ git push -u origin master

-------------------------------------------------- -------------------------------------------------- -----------------------
second embodiment, a cut out in the master dev branch based on the branch, and then modified, and modified done on dev branch, dev branch and then merge into the master branch
# first switch to the dev branch
$ git Checkout -b dev
$ echo "abc" >> README.md
temporary file # added to commit
$ git the Add README.md
# commit the changes
$ git commit - m 'the commit'
# upload the modified local repository to the remote repository
$ Git Checkout Master
$ Git Merge dev
# Upload modify the local repository to the remote repository
$ Git Push -u Origin Master
----------- -------------------------------------------------- -------------------------------------------------- ------------
Note before if we push, upstream of the warehouse was made to modify the code, then the time you local and remote repository code is not up to date, then the need to code upstream warehouse incorporated into local, then push to a remote repository
# added upstream of the warehouse address
Git the Add Remote upstream https://github.com/mlperf/inference.git $
# View origin and upstream corresponding warehouse correct
$ git remote -v

origin corresponds to their own github address that yourname / Project
upstream corresponds to the address of the original project, that SourceName / Project
# get the latest code merged into the master branch own local repository from the upstream repository
$ git pull upstream master
recommended every Code to be submitted twice before, both pulled from the original project at the latest code, and finally use the git push command changes sync to your remote Github repository:
$ git push -u Origin Master
5, will be submitted to a remote repository code upstream warehouse:
enter the remote repository GitHub account at this time have been able to see the changes just submitted from a local warehouse, and then click New pull request

Comparison of results page, as shown below:

I can see to submit code to apply upstream master branch warehouse from a remote master branch library
Able to represent your code upstream code does not conflict merge, you can submit
and then click create pull request, go to the following page:

Fill out the comment describing the changes you made, and then click the lower right corner submit

Then enter the address of the upstream of the warehouse, in the list of Pull requests upstream repository where you can see their submitted requests, waiting for the audit to author


Appendix:
If it is google code, then submit the code developer agreement to agree, then need to sign up for Gmail mailbox, apply for Google Individual CLA, and then use the code to modify and submit via gmail mailbox validated, the robot will google through your submit the code verification, pull request submitted otherwise the application can not be verified by
the ready gmail mailbox, configure your personal mailbox configuration github github account in

Then submit the code should be set at the command line git-mail
git config --global user.email [email protected]
then step 1

 

Guess you like

Origin www.cnblogs.com/javaIOException/p/11867988.html