-
Notifications
You must be signed in to change notification settings - Fork 25
Team Working in Git
Requirements
- Git - http://git-scm.com/
- account on github.com - https://github.com/
- eclipse http://eclipse.org
Here's a glossy description of how we use Git & GitHub: https://guides.github.com/introduction/flow/index.html
In order to contribute to Debrief you should follow next steps:
- enter https://github.com/debrief/debrief in your browser
- sign-in to github
- click the Fork button
- you can accept defaults in the "Fork debrief/debrief" page and click the "Fork Repository" button
You will get your copy of the main Debrief repository with SSH URL as: git@github.com:pecko/debrief.git Replace "pecko" with your github username that you will see in your Debrief page (git@github.com:<YOUR_USERNAME>/debrief.git)
cd ~
// you can use some directory
git clone git@github.com:<YOUR_USERNAME>/debrief.git
cd debrief
Notice: it is your repository containing your username in the URL.
This step is obliged in order to sync your repository with main debrief repository
git remote add upstream git@github.com:debrief/debrief.git
The upstream reference is usual, but you can select some other valid reference.
Notice: You enter the URL of main repository here containing debrief, but not your username.
From your local repository enter:
git fetch upstream
git push origin
The push updates your forked repository. Steps 1-4 are done only once (beside you move to other local machine)
If you want add a new Debrief feature or fix a ticket, you would start with creating a new branch:
git checkout -b myfeature
You can use this command even you forget it and makes some change in your master branch (if you don't commit it).
5.2 Coding ...
Make your code changes.
5.3 Committing
Enter the following in your myfeature branch
git commit -a -m "My Feature"
5.4 Rebasing/syncing
The main tree can be changed during your coding. You have to rebase.
git checkout master
git pull --rebase upstream master
// your remote reference is upstream
git fetch upstream
// update tags from main repo
git push origin
git checkout myfeature
git rebase master
If there is a conflict you have to fix it.
5.5 Push your branch
git push origin myfeature
go to on your github Debrief page and select Pull Request
select your branch and main repository branch (usually debrief/debrief)
click Create Pull Request
7.1 commit all new changes
git commit -a -m "A new request"
or add in existing commit
git commit -a --amend
7.2 push branch
git push origin
or
git push origin -f
// if you change existing commit
7.3 repeat the procedure 6.
The PR will be updated automatically on github.
You should enter these commands periodically:
git checkout master
git pull --rebase upstream master
// your remote reference is upstream
git fetch upstream
// update tags from main repo
git push origin
Now you can rebase your outstanding branches and update the PRs.
When your PR has been merged, you can safely remove corresponding branch in local and remote repository.
git branch -d <branch_name>
//remove local branch (or git branch -D <branch_name>)
git push origin :<branch_name>
// remove remote branch
9.1 Reviewing pull request
The "SomeUser" user creates branch hotfix against master in its fork 'https://github.com/SomeUser/debrief.git' and create pull request. We can review it in the following way:
git checkout -b review-hotfix master
// review-hotfix can be some name
git pull https://github.com/SomeUser/debrief.git hotfix
Reviewing the PR ...
9.2 Merging pull request
If the PR created in step 9.2 is fine, you can merge the PR.
git checkout master
git merge review-hotfix
or git merge --no-ff review-hotfix
, but it will create one additional commit (merge branch XXX)
git push origin master