FiAngulartje git workflow - SoftwareSandbox/FiAngulartje GitHub Wiki
FiAngulartje git workflow
Setting up the repository
First, you need to make sure you have a repository to work on. To do this, you need to fork the SoftwareSandbox repository. Go to https://github.com/SoftwareSandbox/FiAngulartje and click the ‘Fork’ button in the top right:
Now, you should have a ‘FiAngulartje’ repository under your own name. This contains all the branches and commits that are in the SoftwareSandbox’s repository, but they are not hard linked. This means that changes to the SoftwareSandbox repository don’t have any impact on your own repository and vice versa.
To get this repository local, you need to clone it. Go to your own version of the repository and get the correct url on the right of the page. You can choose which authentication to use (https/ssh) by clicking on the links below the input box:
I’ll be using https in this document. Copy the correct url and go to the desired local directory in your command line. Next, use following command to clone the repository: git clone https://github.com/toonborgers/FiAngulartje.git
. This will create a directory FiAngulartje and put the repository there.
If you go into the FiAngulartje directory and run git remote –v
you’ll see that there is a hard link to your github repository:
We also need to add a link to the SoftwareSandbox repository to synchronize changes. First get the repository url the same way you got your own repository url. Next, add the remote using following command: git remote add upstream https://github.com/SoftwareSandbox/FiAngulartje.git
. If you run git remote –v
again you’ll see the new entry:
Now, we’re ready to start working!
Implementing a feature
Before starting on a feature, make sure you have the latest code from the SoftwareSandbox: git pull upstream master
.
The current situation will be:
To do our work on, we’ll create a new feature branch: git checkout –b feature
. The new situation:
After we’ve done our work on the feature branch, we can commit it:
git add –A
git commit –m “some commit message”
The situation now looks like this:
Next, we need to make sure we pull in any changes that might have been made on SoftwareSandbox: git pull upstream master
. If there were changes made on SoftwareSandbox and git can merge them automatically, the situation looks like this (C6 is the merge commit created by git):
When this is done, we’ll push our new branch to our repository on github: git push –u origin feature
. The current situation:
To get our changes into the SoftwareSandbox repository, we’ll need to create a pull request. To do this, go to the SoftwareSandbox repository on github. There you’ll see this banner:
Click the ‘Compare & pull request’ button. On the next page, you can comment on your pull request. Here, you can explain the pull request (e.g. ‘Fix issue #34’). When you’re happy with your comments, click the ‘Create pull request’ button.
On the following page, you can see a Travis CI build is triggered:
Wait for this to complete successfully before merging your pull request. If there are failures, fix them and push your changes to your repository. New commits will be added to the pull request and a new Travis build will be started.
When the build runs successfully, the page looks like this:
Click ‘Merge pull request’ and ‘Confirm merge’ to merge the pull request into the SoftwareSandbox repo. Ideally, this should be done by someone else to have some code review.
If you’re done with your feature, you can delete the branch on your github repository by clicking the ‘Delete branch’ button.
After this, the situation looks like this:
You can locally remove your feature branch by switching to master and deleting feature:
git checkout master
git branch –D feature
That’s all folks!