Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Git Configuration

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 563
    Comment on it
    Previous Git Blogs


    Intialize git repostiory
    First Commit
    Two tree architecture and Three tree architecture
    Best basic practices for writing commit messages
    Viewing the commit logs
    Git Basic WorkFlow
    What is HEAD pointer in GIT

    Git provides three level of configuration


    1. System Level Configuration
       git config --system
    2. User Level Configuration
      git config --global
    3. Repository Level Configuration
      git config which is stored in .git/config in each repo

    Its not very common to do sytem levl configuration we normally do User level configuration and Repository Level configuration.

    Lets see whats in .gitconfig file

    naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ cat ~/.gitconfig
    Git Display:
    [push]
        default = matching
    

    lets see what is in --global list

    naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git config --global --list
    Git Dispaly:
    push.default=matching
    actually nothing there Now lets Set the global options
    naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git config --global user.name "naveenkumar"
    naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git config --global user.email "er.navvy@hotmail.com"

    Show me all varaibles in global list:

    naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git config --global --list
    Git Display:
    push.default=matching
    user.name=naveenkumar
    user.email=er.navvy@hotmail.com
    

    Now if I run the above command for gitconfig

    naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ cat ~/.gitconfig
    Git Display:
    [push]
        default = matching
    [user]
        name = naveenkumar
        email = er.navvy@hotmail.com
    
    its a name value pair file, with header [user] with individual property name and email. This is how we set global user options in GIT

    some other option we can set

    Set core editor

    git config --global core.editor vim
    Set help autocorrect

     git config -- global help.auto correct 1
    what it does, if mistype the command Git will guess what you wanna use and will show you the message about the command you wanna use and run it. for example:- I run a command with wrong spell of status
     naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git stsus 
    Git Display:
    git: 'stsus' is not a git command. See 'git --help'.
    
    Did you mean this?
        status
    

    Now I set the global autocorrect to 1

    naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git config --global help.autocorrect 1
    Now below you can see again I run the command with wrong spell of Status
    naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git stats
    Git Display
    WARNING: You called a Git command named 'stats', which does not exist.
    Continuing under the assumption that you meant 'status'
    in 0.1 seconds automatically...
    On branch master
    nothing to commit, working directory clean
    

    it execute the command with guessing . This could quite dangerous some time.

    so reset global option back to default

    naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git config --global help.autocorrect 0
    List all of the options you have set
    naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git config --global --list
    Git Display:
    push.default=matching
    user.name=naveenkumar
    user.email=er.navvy@hotmail.com
    help.autocorrect=0
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: