Showing posts with label git branch. Show all posts
Showing posts with label git branch. Show all posts

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!

Wednesday, 15 September 2010

Beginner's guide to : Create a Git branch

Lets say you want to have a working branch, here's what you need to do.
On your local (automatically added to your remote repo):

$ git push origin master:refs/heads/branchName
e.g.: git push origin master:refs/heads/mybranchname

means that you will create a new branch named 'mybranchname' to the remote repository, copying everything from master.



Next step :

$ git checkout branchName
e.g.: git checkout mybranchname

moving, fetch, and start to work on branch 'mybranchname'



Enjoy!