-
Notifications
You must be signed in to change notification settings - Fork 0
Git step by step
Say we're going to work on bug 1234, and the only file that needs to be changed is system/jlib/jfile.cpp
###(0). Set up and configuration
0a: Install git and fork the hpcc-systems/HPCC-Platform project following the help.git guidelines:
http://help.github.com/win-set-up-git/
http://help.github.com/fork-a-repo/
0b: Assuming git was installed and git remotes are setup:
$ git remote -v
origin [email protected]:<user>/HPCC-Platform.git (fetch)
origin [email protected]:<user>/HPCC-Platform.git (push)
upstream [email protected]:hpcc-systems/HPCC-Platform.git (fetch)
upstream [email protected]:hpcc-systems/HPCC-Platform.git (push)
0c: Your .gitconfig file (in ~/ for linux or \Users<user> for windows 7) should contain the following:
[core]
autocrlf = true
whitespace = trailing-space,tab-in-indent
[apply]
whitespace = error
And you should rename the file .git/hooks/pre-commit.sample in each of your local repository directory to pre-commit.
Comments: 1 - with the steps in 0c the rules for trailing spaces and tabs will be checked before committing. You can also use git diff --check to do this explicitly before committing. 2 - please refer to the wiki page Preferred Git Settings
###(1) Resync
Before making any changes, switch to master locally and download the latest from upstream
git checkout master
git fetch upstream
git merge --ff-only upstream/master
git push origin master
###(2) Branch
Create branch for the bug and switch to it
git checkout -b bug1234
Comment: You can alternatively use those 2 commands:
git branch bug1234
git checkout bug1234
And, if the branch bug1234 already exists, simply:
git checkout bug1234
###...Make changes to the file....
###(3) Stage
Stage the file locally
git add system/jlib/jfile.cpp
Comment: If you add -a option to the commit command in step 4 below, this step is not necessary except for new files.
###(4) Commit Commit the file locally, sign the commit message with your username with the -s option
git commit -s -m "Bug: 1234 - pretend bug"
###(5) (Optional but recommended) Rebase
If you have been working on the bug for a while and master is likely to have changed you should rebase your branch before pushing. This is optional, but is recommended to always do it before submitting a pull request because this will make it much more likely the branch will merge without problems.
5a. First resync your master with upstream by executing step 1 above.
5b. Then rebase your branch:
git checkout bug1234
git rebase master
###(6) Push
Push the committed change to the remote fork
git push origin bug1234
Comment: If you have already pushed some of your changes to origin, and the rebase on master brought in some extra commits, you will get a fast forward error when you try to push. If that happens you need to add a plus sign to the push command:
git push origin +bug1234
###(7) Generate Pull request
Generate and Send out the pull request from github.com