-
Notifications
You must be signed in to change notification settings - Fork 51
4. Coding guide: github (fork workflow)
Feel free to contact me if you have any troubles, questions, comments, wishes, etc.
Adapted from atlassian
Create an account on GitHub
-
Fork the 'official' server-side repository
RGPR
. This creates your own server-side copy -
Clone the new server-side copy to your local system
git clone https://github.com/username/RGPR.git
and move to the created "RGPR" repository
cd RGPR
-
Add Git remote path for the 'official' repository to the local clone
convention:
-
origin
= name of the remote for your forked repository (automatically created when you run git clone) -
upstream
= name of the remote for the official repository.
create the upstream remote:
git remote add upstream https://github.com/emanuelhuber/RGPR.git
-
-
Check if the connection with the github works
git remote -v
- Before you create a new branch, make sure that:
- you are in the master branch (i.e., the checked out branch is master)
git checkout master
- the master branch on your local machine is up-to-date with the official master branch
git pull upstream master
- you are in the master branch (i.e., the checked out branch is master)
- Create a new local feature branch and switch to it
Notes:
git checkout -b feature_branch_name
-b
argument is to switch directly to the created branch - Push the branch on github :
Notes:
git push origin feature_branch_name
- execute
git branch
to find out the local branches (the branch marked with an*
is the checked out branch). - execute
git branch -r
to find out the remote branches.
- execute
-
Make some changes
-
Make sure you are in your branch before you commit something
git branch
The branch marked with an
*
is the checked out branch. If you are not in your branch, move to itgit checkout <name_of_your_new_branch>
-
Commit the changes you made:
git add -A # equivalent to git add --all git commit -m "a commit message in the present tense"
-
Push the branch to your remote repository
git push origin feature_branch_name
One of the key points of the feature branch workflow is that the developer who wrote the code does not merge the code with master until there has been a peer review.
- check that your branch is up-to-date with the official branch
git pull upstream master
- Push the branch to the developer's own server-side copy
git push origin feature_branch_name
- Open a pull request on github (go to your branch, click on "New pull request").
- Your pull request will be first reviewed:
This experience also allows the peer reviewer to place a comment on any line within the update. This will be communicated back to the editor of origin. This review experience really allows for everyone on the team to be actively involved in each update.
- Once the reviewer has approved the editors updates, the pull request gets approved for merge and is merged into the original server-side repository Once the branch is merged, delete the obsolete branch from your local repository:
git checkout master
git branch -d feature_branch_name