Git & Github in a nutshell - franleplant/javaraptors.backend GitHub Wiki

The idea of this page is to get you fast on track to start using the amazing git. Please note that this is a pragmatic learning and in no way replace reading the official git docs or any other detailed tutorials.

Let's suppose that you need to implement a a login for the system (new feature).

Then you create a feature branch called login.

In master branch:

git checkout -b login

Now you are in login branch

Write some code and commit it:

git add file_changed1
git add file_changed2
...
git add file_changedn

git commit -m "Write a message describing the changes in here"

This process should be done several times a day, the more atomic a commit is, the better.

Before you push the changes to GitHub you need to be sure that your login branch is based on the most recent master branch:

git rebase master

This is likely to have merge conflicts, resolve them! This process should be done few times a day.

The rebase process is important, because it will make easier the merge with master branch process.

When you are ready push the changes to GitHub, to the login branch

git push origin login

This process should be done few times a day.

GitHub Pull Request

Now you should be able to see your branch in GitHub.

When your feature, login, is ready and up in GitHub then you should submit a Pull Request (in GitHub's web site):

  • Select your branch.
  • Pull Request (up right corner of the File list wrapper)
  • You should see that login branch is trying to merge master
  • Create the Pull Request
  • Tell your partner to review and Accept and Merge it (Fran)

IMPORTANT: ONLY ANOTHER PARTNER CAN MERGE A PULL REQUEST, DONT MERGE YOUR OWN PULL REQUEST. Request help to Fran or to Javi or Pablo.

Common not-core tasks

What are my remotes?:

git remote -v

You should set the remote origin if you don't have it:

git remote add origin github_url

When you want to see the changes that you introduced into a file:

git diff file_name