GIT hacks

    • Use the command below after modifying .gitignore and to remove tracking files already committed before git rm -r --cached .
    • List all the files currently being tracked under the branch master
      git ls-tree -r master --name-only
    • Print a decorated log of branches on command line git log --all --decorate --oneline --graph

  • To remove a particular file/folder from remote but not from the local folder:
    # remove the file from cache of tracked files
    git rm --cached {filename}
    # remove the file from cache of tracked folders
    git rm --cached -r {foldername}
    # committing the changes
    git commit -m "Removed folder from repository"
    # pushing to remote
    git push origin master
    
  • To store user credentials in a cache to avoid logins for every commit:
    # to cache the login credentials
    git config credential.helper cache
    # This command will store your credentials for 3600 secs.
    # Hence username and password will not be asked for 3600 secs.
    git config credential.helper 'cache --timeout=300'
    
  • To list all global configurations of git
    git config --global --list
    
  • To add global configurations such as user-name and user-email
    git config --global user.name "John Doe"
    git config --global user.email "johndoe@email.com"
    

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s