-
Notifications
You must be signed in to change notification settings - Fork 303
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
0a: Install git and fork the hpcc-systems/HPCC-Platform project following the help.git guidelines:
0b: Assuming git was installed and git remotes are setup:
$ git remote -v
origin git@github.com:<user>/HPCC-Platform.git (fetch)
origin git@github.com:<user>/HPCC-Platform.git (push)
upstream git@github.com:hpcc-systems/HPCC-Platform.git (fetch)
upstream git@github.com:hpcc-systems/HPCC-Platform.git (push)
0c: Your .gitconfig file (in ~/ for linux or \Users<user> for windows 7) should contain the following:
[if you don't find .gitconfig there in Windows 7, check/edit the "Start In" field in the Properties for your Git Bash icon]
[core]
#windows
autocrlf = true
#linux
autocrlf = input
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
Before making any changes, switch to master locally and download the latest from upstream
git checkout master
git fetch upstream
git submodule update --init --recursive
git merge --ff-only upstream/master
git push origin master
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....
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.
Commit the file locally, sign the commit message with your username with the -s option
git commit -s -m "HPCC-1234 Pretend bug"
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
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
Generate and Send out the pull request from github.com
Having made changes to local code, amend the original commit:
git commit -a --amend -s
And force an update to origin:
git push -f origin
Now you can refresh the pull request page in github...