Git workflow
Thomas Perret edited this page Aug 1, 2016
·
20 revisions
Configure remote repos:
git remote -v # show all remote repo
git remote add origin https://github.com/pyhrf/pyhrf.git #official repo
git remote add upstream https://github.com/myuser/pyhrf.git #my fork of repo (forked on github)
May be needed to interact with another contributor:
git remote add otheruser https://github.com/myfriend/pyhrf.git #my friend's fork
in the file pyhrf/.git/config : to the section origin, add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
Prepare new feature -> describe the feature on GitHub with a ticket or assign youself to an existing one | open a new issue on GitHub and label it or work on ticket |
Start a new feature -> create a new descriptively-named branch | git checkout -b new-dev |
Write doc, tests, implement -> Declare files to be commited | git add new_dev.rst test_new_dev.py new_dev.py |
When a sub-stuff seems completed -> commit locally | git commit -m '[#<ticket_number>] my stuff started' |
Loop while continueing to work | git add ... ; git commit -m '[#<ticket_number>] ...' |
Before pushing upstream, check that you are up to date with master branch in main repository. | git fetch origin; git checkout master; git merge origin/master |
If previous command updated your master branch rebase your feature branch on master. Resolve conflicts if any. | git checkout new-dev; git rebase master |
When the feature is ready to publish -> push to your fork of pyhrf on your github | git push upstream new-dev |
To ask for feedback and for merge on master -> do a pull-request on Github -> indicate that the PR closes the ticket | Login to your github account an open a Pull-request from it |
Someone else review your PR
|
git cmds:
|
If someone else wants to checkout updated PR |
git cmds:
|
See comments on the PR on github Wait for close or approval |
|
Once PR is treated, if merge occured
|
git cmds:
|
Close the dev of the new feature
|
git cmds:
|
Sketch of the workflow:
## official repo on Github ## ## fork on user account ##
pyhrf:pyhrf/master /_____PR______ __ user:pyhrf/my-branch
\ /\
\ /
\ /
\ /
git pull origin git push upstream my-branch
\ /
_\| ## local repo ## /
origin/master upstream/my-branch
-
Show a nice history log:
git log --oneline --decorate --color --graph git log --pretty=format:"%C(auto)%h %ar %d %s %C(bold blue)<%an>%Creset" --decorate --color --graph
-
You can also add an alias:
git config --global alias.hist 'log --pretty=format:"%C(auto)%h %ar %d %s %C(bold blue)<%an>%Creset" --decorate --color --graph' git hist