Sunday, October 21, 2012

Setting up Git and Gitorious.org

1. Backup any existing ssh keys
     $ cd ~/.ssh/
     $ mkdir key_backup
     $ mv *.pub ./key_backup/

2. Generate private ssh keys
     $ ssh-keygen -t rsa -C "developer.rps@gmail.com"
     $ Enter file in which to save the key: filename
     $ Enter passphrase : *****

3. Add private ssh key to git.gitorious.org account
     $ sudo apt-get install xclip
     $ xclip -sel clip < ~/.ssh/filename.pub

       - go to account setting in the user page of git.gitorious.org
       - Go to your Account Settings
       - Click ssh keys
       - Click "Add SSH key"
       - Paste your key into keyfield
       - Click Add key

4. Check whether ssh key is successfully added
     $  ssh -v git@gitorious.org


5.1. Clone the remote repo
     $ mkdir ~/workspace/
     $ cd ~/workspace
     $ git clone git://gitorious.org/athena/athena


5.2. Create remote repo from existing local repo
     $ mkdir ~/workspace/
     $ cd ~/workspace
     $ # add files if not already exist
     $ git init
     $ git remote add origin git@gitorious.org:athena/athena
     $ git commit * -m "some message"
     $ git push origin master


6. Adding files to remote repo
     $ cd ~/workspace/athena
     $ nano someFile.txt

7. Add some msg to it, save and exit
     $ git add someFile.txt
     $ git status
     $ git commit -a
     $ git remote set-url --push origin git@gitorious.org:athena/athena.git
     $ git push origin master #only for the first time,
     $ #next time onwards just use "git push")

   If the step 7 throws an error like this,
          $ Permission denied(publickey).fatal:The remote end hung up unexpectedly

  do the following, then try pushing
     $ ssh-add ~/.ssh/id_rsa.pub
     $ git push

8. Getting files from remote repo
     $ git pull



7. Start a new branch
     $ git branch feature-A
     $ git branch -a

8. Select new branch
     $ git checkout feature-A

9. Push commits on new branch to remote repo
     $ git push origin feature-A

10. Merge new branch with master
     $ git checkout master
     $ git merge feature-A

11. Delete a local branch
     $ git branch -D feature-A

12. Delete a remote branch
     $ git push origin --delete feature-A

2 comments:

 

Copyright © Project Athena Design by O Pregador | Blogger Theme by Blogger Template de luxo | Powered by Blogger