Using git and github for projects

From PG_Wiki
Jump to: navigation, search

Git is a source code management tool.More on git here. 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:

 $ sudo apt-get install git-core git-gui git-doc
  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.

 $ git remote add origin 

Sets the origin for the local Backchannel repo. is public url of your github repo. You will find this when on your github repo page.

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
 git commit -m "first commit"
 git push origin master
 $ git clone
 git fetch
 git status
 git branch

So typical workflow once you create a repo is:

 git fetch
 git add foo.rb
 git status
 git commit -m "commit msg"
 git push
Personal tools