Monthly Archives: February 2017

Git cheat sheet

  • Replace crlf

git config core.autocrlf true


  • Remote branch delete

git push origin --delete <branchName>


  • Apply new gitignore

To untrack a single file that has already been added/initialized to your repository, i.e., stop tracking the file but not delete it from your system use: git rm --cached filename
To untrack every file that is now in your .gitignore:
First commit any outstanding code changes, and then, run this command:
git rm -r --cached .
This removes any changed files from the index(staging area), then just run:
git add .
Commit it:
git commit -m ".gitignore is now working"

To undo git rm –cached filename, use git add filename


  • Undo all uncommitted changes

git checkout .


  • file log

Git log -1 --

  • fix error Cant't ref..

$ git gc --prune=now

$ git remote prune origin


  • 恢复误删除文件, notepad++ 把换行\r\n换成;一次执行多个文件
  1. Use git log –diff-filter=D –summary to get all the commits which have deleted files and the files deleted;
  2. Use git checkout $commit~1 filename to restore the deleted file.


  • Prevent gc

git config --global 0


  • View file log

Gitk <filename>


  • Getting existing git branches to track remote branches

git branch --track origin/branch_name


  • rollback git repo to specific commit

git reset --hard <tag/branch/commit id>
git checkout HEAD -- my-file.txt

  • Log search

git log --grep="Build 0051"


  • reverting specific commits from git
    $ git revert --no-commit b49eb8e 1d8b062
    Files that were modified in those 2 commits will be changed in your working directory
    If any of those 2 commits had changed ‘a’ then you could discard the revert for it:
    $ git checkout a
    $ git commit -a -m "Revert commits b49eb8e and 1d8b062"


Config proxy for Nuget

  1. Download Nuget.
  2. Open command line, in folder of Nuget.exe, press Alt+Shif+F, select open command window here

Commands to set nuget proxy

nuget.exe config -set http_proxy=http://my.proxy.address:port
nuget.exe config -set http_proxy.user=mydomain\myUserName
nuget.exe config -set http_proxy.password=mySuperSecretPassword

Commands to view nuget proxy

nuget.exe config http_proxy
nuget.exe config http_proxy.user
nuget.exe config http_proxy.password