Friday 8 October 2010

Beginner's guide to : Starting to work on project with existing git repository

The other day I have a colleague scanning through this blog to find a way on getting started to work with git repository (he found none because I haven't write it down here), so I think it won't hurt to actually write it. So here goes...

The case is, you need to work on a collaboration project, git repository is made (or maybe the project is half-way already), but you are clueless on what/how/when to start working with the repository.

what you need to do :

  1. Sign up to github.
  2. Register your public key here : Account Settings > SSH Public Keys
    or run this ssh-keygen -t rsa on a console if you don't have public key yet
    can be found later on ~/.ssh copy whatever inside id_rsa.pub
  3. Run these below on your console, to set up your username & email :
    $ git config --global user.name yourusername
    $ git config --global user.email youremail@yourdomain.com
  4. Ask your team leader/whoever has access to the original repository to invite you into their organization.
    In case they are clueless:
    Dashboard > Switch context into the organization's > Teams
  5. Once they've invite you, go to their repository page & copy the SSH url, supposedly with the write & read access.
  6. Go to your terminal run :
    $ git clone git@github.com:organization_name/repo_name.git
    $ cd repo_name
  7. If somehow you need the repo's branches, run this:
    $ git branch -r
    $ git fetch origin repo_branch_name:local_branch_name
  8. Create your working branch like so : (here for more detailed info)
    $ git push origin master:refs/heads/mynewbranchname
  9. Checkout to your new working branch with this line :
    $ git checkout mynewbranchname
  10. There you go, you're all set to rock your project!

No comments:

Post a Comment