This guide is written around the gitflow workflow using GitHub and will cover some basic training topics (Pull requests, conflicts etc).
Before we can begin with our tutorial, there is a bit of setup involved to help us along the way.
Please fork this repository by clicking the Fork
button on the top right hand side
Once the project has been forked, proceed by cloning the repository
git clone ssh://git@github.com/YOURNAME/training_git
To be able to pull in changes from the blessed repo we need to add it as an upstream
git remote add upstream ssh://git@github.com/Wizcorp/training_git.git
Here we will take you through the pull request process and have you perform your first pull request. What you will be
doing for your first fix is to update the title of this README file training-git
to Training - GIT
. Please follow
the following instruction set to get to the PR review stages:
Create a branch dedicated to your fix, branching it from the master branch
git branch feature/titleFix master
Now that the branch has been created, you will need to check it out to make changes
git checkout feature/titleFix
From this point you can begin making changes, please alter the README.md
file title to Training - GIT
Before we begin committing our work, let's take a quick look at the status of the project
git status
We now have to commit our work, so firstly we need to stage the changes
git add README.md
And then we commit it
git commit -m "YOUR COMMIT MESSAGE HERE"
At this point we should usually pull in any changes that may have occurred in the meantime on the master branch
git pull upstream master
Then we push the branch up to our fork creating the branch on the remote
git push origin feature/titleFix
Lastly we initiate a pull request to the origin blessed repository using the Pull Request
button from your fork
Here we will help you face and resolve a git conflict by trying to simulate the situation. We have the following
sentence She sells sea-shells on the sea-shore.
. What we will do is modify this sentence to contain by the seashore
as opposed to on the sea-shore
.
git branch feature/sentenceFix master
git checkout feature/sentenceFix
Modify the above sentence as written there.
git status
git add README.md
git commit -m "YOUR COMMIT MESSAGE HERE"
Here to simulate the conflict resolution we will pull from a different upstream branch conflict
git pull upstream conflict
You should now be faced with a conflict. You can quickly check which files contain a conflict by taking a look at this
project status
. When you open the file you should notice a section wrapped by <<<<<
, =====
and>>>>>
. The goal is
to remove one or merge then together into one. Once you have resolved the conflict, removed the encapsulation text
<<<<<
, =====
and>>>>>
.
git push origin feature/sentenceFix