This repository was archived by the owner on Oct 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Git
Zhao Lu edited this page May 20, 2014
·
11 revisions
Find a deleted file:
git log --diff-filter=D --summary | grep make_release(finds the deleted file 'make_release', from commit summary)
Restore a deleted file from previous commit:
zlu@zlu-mba:~/projects/foo (master +)$ git rev-list -n 1 HEAD -- 'public/assets/images/bg.jpg'
d4fa41b7ce3d976b59d165742ab8351d410b0d47
zlu@zlu-mba:~/projects/foo (master +)$ git co d4fa41b7ce3d976b59d165742ab8351d410b0d47^ -- 'public/assets/images/bg.jpg'Find a deleted string, such as 'pjax-page':
git log -S'pjax-page' path-to-fileFirst git commit
git rev-list --max-parents=0 HEAD | xargs git showClear git cache
files specified in .gitignore are not ignored: gitignore only ignores files that are untracked. once the file is tracked, you need to clear the cached file index
git rm -r --cached .
git add .
git commit -m '.gitignore should work now'Find a commit by text
zlu@zlu-mba:~/projects/zeeweibo (master +)$ git log -S 'country_select'
commit b7255a07f62df4b548bfe736fae8da6ff0b85b00
Author: zlu <zlu@me.com>
Date: Thu Dec 13 23:07:26 2012 -0800
added country-selector plugin for activeadminGet update from remote
zlu@zlu-mba:~/projects/zeeweibo (master)$ git remote update
Fetching origin
Fetching bb
remote: Counting objects: 47, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 8 (delta 7), reused 6 (delta 5)
Unpacking objects: 100% (8/8), done.
From ssh://bitbucket.org/zlu/foryogi
* [new branch] map-fix -> bb/map-fix
* [new branch] nav -> bb/nav
* [new branch] studio-show -> bb/studio-showCheck out and track remote branch
zlu@zlu-mba:~/projects/zeeweibo (master)$ git co --track bb/studio-show
Branch studio-show set up to track remote branch studio-show from bb.
Switched to a new branch 'studio-show'This also switch to the new branch locally.
What changed since
git whatchanged --since="13 days ago" -p