Index ¦ Archives

Github Workflow

Employment wise, it is better to know how to use Git from the command line than via a tool

  • git brings up a list of all available commands.
  • git init initialises a new repository(repo). This allows you to clone it right away.
  • git remote add ... to communicate with the outside world, git uses what are called remotes. These are repositories other than the one on your local disk to which you can push your changes into (so that other people can see them) or pull from (so that you can get others changes). The command git remote add origin [HTTPS clone URL] creates a new remote called origin located at HTTPS clone URL. Once you do this, in your push commands, you can push to origin instead of typing out the whole URL.
  • git clone repo-url to download a repo onto your machine.
  • git status to check the tracked status of files in a local repo.
  • git add file-name or git add --all to track new files locally before pushing them to Github.
  • git commit -m 'message to lock(stage) a file into the local repo before it is pushed to Github.
  • git push to upload staged files to Github.
  • git pull to get changes on Github into the local repo.

Day to Day Workflow

  • git pull first thing in the morning.
  • git add new files.
  • git commit uncommited work.
  • git push send files to Github.

Branching

  • git branch to see all branches
  • git branch branch-name to create a branch where branch-name is the name of a new feature.
  • git checkout branch-name to work on a specific local branch.
  • git merge branch-to-merge-into-this to merge in code of another branch into that which is currently checked out. Typically you would work with a branch then merge master into it; resolve any conflicts and push. You can then create a pull request for it. Make sure that master is an up to date copy.
  • git push origin master is a command that says "push the commits in the local branch named master to the remote named origin". Once this is executed, all the stuff that you last synchronised with origin will be sent to the remote repository and other people will be able to see them there.

A pull request pushes your code up to Github for other people to see and peer review. You create the pull request in Github where you can delete it after the merge is made.

See http://bit.ly/1zgNqM9 for more details. esc:wq for saving from large commit windows.

© Imran Nazir. Built using Pelican. Theme by Giulio Fidente on github.