- 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 -- file.name
- fix error
Cant't ref..
$ git gc --prune=now
$ git remote prune origin
- 恢复误删除文件, notepad++ 把换行\r\n换成;一次执行多个文件
- Use git log –diff-filter=D –summary to get all the commits which have deleted files and the files deleted;
- Use git checkout $commit~1 filename to restore the deleted file.
- Prevent gc
git config --global gc.auto 0
- View file log
Gitk <filename>
- Getting existing git branches to track remote branches
git branch --track origin/branch_name
[source](http://stackoverflow.com/questions/1184518/getting-existing-git-branches-to-track-remote-branches>
- rollback git repo to specific commit
git reset --hard <tag/branch/commit id>
git checkout HEAD -- my-file.txt
source
source2
source3
- 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"