Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Thursday, June 13, 2013

Steps to work with GIT for dummies

Today I start working with BitBucket (GIT) and found it bit difficult in comparison to SVN. I  have to read lots of documentations to work with GIT and finally I succeed in it. But I made a note of all the steps for the beginners. Follow these steps and play with GIT.

1. Registration on BitBucket.org: Register on bitbucket.org and create a repository there.
Steps to work with GIT for dummies

2. Setup GIT on local machine: Here comes little difficult task but not now.

2.1 Installing GIT package: To install GIT packages on your local machine/VM, open putty and execute below commands:
      rpm -Uvh http://mirror.webtatic.com/yum/centos/5/latest.rpm
Install GIT package.
   yum install --enablerepo=webtatic git-all

2.2 Create directory and navigate: Now create a directory in which you will clone the repository.
   cd /var/www/ ( This location is subject to user's choice.)
    mkdir sysadmin
    cd sysadmin
2.3 GIT initialization & cloing: Now initialize and clone the GIT repository on local macine/VM. To get the clone url of repository, click on Clone and then copy clone url of repository.
Steps to work with GIT for dummies


   git init
   git remote add origin https://gauravsaini@bitbucket.org/vickeyrihal/sysadm.git
   git clone https://gauravsaini@bitbucket.org/vickeyrihal/sysadm.git
2.4 Adding a file to GIT Repository: Now a new file to the repository from your local machine. git add command will be used to add any file in repository.
   touch sample.txt
   vi sample.txt
   git status
   git add sample.txt
2.5 Committing file to GIT Repository first time: After adding file in repository now its time to commit and push the file to repository. For doing this, git commit and git push command will be used. Its a good habbit to always check the git status before committing any file.
-a : to commit all the files.
-m : add message while committing any file for reference.
Note: When first time commit is  performed in GIT repository then we need to execute git push origin master command. Next time only git push will be enough. 
   git status
   git commit -a -m"First Commit"
   git push origin master 
2.6 Commiting a file to GIT Repository second time: Committing changes into repository second time.
   vi sample.txt
   git status
   git commit -a -m"second commit"
   git push
2.7 Configuring user name & email: GIT might request your details. If requested then supply the details.
   git config --global user.name "gauravsaini"
   git config --global user.email "gaurav81083@gmail.com"
Note: While pushing to GIT, you will be asked for the repository password.

PULL content from repository: To pull the updated content from repository, one need to use GIT PULL commad which will fetch the updates from repository and merge those changes in local working copy.
    git branch [Check the branch of linked repository]
   git branch --set-upstream master origin/master
   git pull
If you feel that I have miss anything then please feel free to write me.

Enjoy bitbucket.

No comments:

Post a Comment