Using git and github for projects: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
(Created page with "Git is a source code management tool.More on git [http://progit.org/book/ch1-3.html here]. github.com is a web application that allows anyone to create an account and host a publ...")
 
No edit summary
Line 8: Line 8:
* github uses SSH keys to setup secure connection between your local repo and the public repo. Go to github help at [http://help.github.com/linux-set-up-git/ Github help] and follow the steps to setup ssh keys
* github uses SSH keys to setup secure connection between your local repo and the public repo. Go to github help at [http://help.github.com/linux-set-up-git/ Github help] and follow the steps to setup ssh keys
* Creating a repository - Lets say we want to create a repository for Backchannel project.  
* Creating a repository - Lets say we want to create a repository for Backchannel project.  
# Create a repository on github
Follow steps at [http://help.github.com/create-a-repo/ 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.
# Create local repository
<br/>Create a directory where the repository will be stored
<br/>Create a directory where the repository will be stored
   $ mkdir ~/backchannel
   $ mkdir ~/backchannel
Line 15: Line 19:
You will get an output like An empty git repository has been initialized on the terminal.
You will get an output like An empty git repository has been initialized on the terminal.
This initializes a git repo locally.
This initializes a git repo locally.
* Create a repository on github
* Connect local and github repos
Follow steps at [http://help.github.com/create-a-repo/ create a gihub repo]
  $ 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

Revision as of 21:36, 27 September 2011

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