RSS

Quick Guide For Git Commands

13 Sep

Here is a list of commands which help you to work with git.

Setup Git
Type following in Git Bash to setup git

Sets the default name for git to use when you commit:
$ git config --global user.name "Your Name Here"

Sets the email id used when committing code:
$ git config --global user.email "your_email@youremail.com"

How to initialize git in a folder
In git bash, navigate to project folder using cd command. Then type following command:
$ git init

Create a file in git folder
Navigate to project folder(git folder) and type:
$ touch<file_name>

Add a file to the list of files to be committed
$ git add<file_name>

Commit changes in local repository(in our machine itself)
Taking a commit means taking a snapshot of current project. The changes are not reflected in main github server now.
$ git commit -m 'first commit'
-m is for message. Here a message “first commit” is added to commit

Push your commit
Pushing our local commits to github server is done first by setting a remote to github repo
$ git remote add origin https://github.com/username/Crater.git
This is a one time action as remote name is created here

Here the remote name is “origin” pointing to repo. Now the master folder is pushed to “origin” using following command
$ git push origin master
Forking a repo
Its done to work on others projects or to start from others work. First move to new project folder and clone the forked repo
$ git clone https://github.com/username/Spoon-Knife.git
This will copy the files and folders to project folder

Adding all files inside git folder to repo
git add *

Creating a Branch
git branch branchname

Select a branch
git checkout branchname

Switching between branches
git checkout master git checkout branchname

Merge a branch
git merge branchname

Delete a branch
git branch -d branchname

Advertisements
 
4 Comments

Posted by on September 13, 2013 in Git

 

4 responses to “Quick Guide For Git Commands

  1. Générateur De kamas

    September 13, 2013 at 7:31 am

    Notre générateur de kamas est enfin terminée et disponible gratuitement en téléchargement.

    Ne perdez pas de temps il n’est disponible qu’en quantité limitée.
    Notre générateur de kamas est garantie de non-bannissement
    avec beaucoups de possibilité intégrée vous garantissant une sécurité optimale.

    Il est important de comprendre que notre programme n’est pas compliquée d’accès et vous permet une
    utilisation sereine en toutes circonstances
    En plus vous allez pouvoir faire des kamas très simplement mais en plus vous êtes sur
    d’être en toutes sécurité grâce à notre moyen de programmation unique utilisant
    des techniques utilisés par les plus intelligents du moment.

     
  2. webpage

    September 13, 2013 at 10:04 am

    You will find a wide variety of hotels, you can certainly
    contact your local Better Business Bureau, your attorney general’s office, or town
    hall, Dann said. On Wednesday, Mr. An informal arrangement may
    be an auction dedicated to art and home decor, or musical instruments, accessories, appliances, studio furniture, and more,
    must go! Gordon Brothers Group and Hilco Merchant Resources liquidation
    group, Borders is beginning its liquidation salesin all 399 remaining
    stores.

     
  3. Get Writing Job

    September 13, 2013 at 5:47 pm

    Magnificent goods from you, man. I’ve bear in mind your stuff prior to and you’re simply extremely great.
    I really like what you have received right here, really like what you are saying and the way in which
    through which you say it. You make it entertaining and you still care for to keep it sensible.
    I can’t wait to learn much more from you.

    That is really a terrific web site.

     
  4. check out here

    September 16, 2013 at 8:40 am

    Withstanding renal disease? australian nephropath explains to every one – exactly how their patients avoid dialysis

     

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: