Using git and github for projects

From Expertiza_Wiki
Revision as of 21:36, 27 September 2011 by Admin (talk | contribs)
Jump to navigation Jump to search

Git is a source code management tool.More on git here. github.com is a web application that allows anyone to create an account and host a public git repository. When you work in teams, we encourage you to set up a repository on github for your project.

Some basic steps:

  • Create an account on github
  • Install git- Depending on your OS, this will vary. For ubuntu
 $ sudo apt-get install git-core git-gui git-doc
  • github uses SSH keys to setup secure connection between your local repo and the public repo. Go to github help at Github help and follow the steps to setup ssh keys
  • Creating a repository - Lets say we want to create a repository for Backchannel project.
  1. Create a repository on github

Follow steps at create a gihub repo This needs to be done only once. i.e. Even if you are working in a team, it is sufficient for only one person to create the repo on github.

  1. Create local repository


Create a directory where the repository will be stored

 $ mkdir ~/backchannel

Init a git repo in that directory

 $ cd ~/backchannel
 $ git init

You will get an output like An empty git repository has been initialized on the terminal. This initializes a git repo locally.

  • Connect local and github repos
 $ git remote add origin git@github.com:username/Backchannel.git 

Sets the origin for the local Backchannel repo. git@github.com:username/Backchannel.git is public url of your github repo. You will find this when on your github repo page.

  • Adding files to git

Any new files you create need to explicitly added to git. It tells git to track the changes in these files.

 git add hello_world.rb
  • Committing the changes to git- This commits all your changes to local repo. These changes have not yet been pushed to the remote repo on github
 git commit -m "first commit"
  • Push changes to remote repo
 git push origin master