Cheatsheet: Difference between revisions
Jump to navigation
Jump to search
Adamcolton (talk | contribs) Created page with "== Git == undo commit $ git commit -m "Something terribly misguided" $ git reset HEAD~ << edit files as necessary >> $ git add ... $ git commit -c ORIG_HEAD find in..." |
Adamcolton (talk | contribs) |
||
| (13 intermediate revisions by the same user not shown) | |||
| Line 9: | Line 9: | ||
find in history | find in history | ||
git log -S'the line from your file' -- path/to/your/file.txt | git log -S'the line from your file' -- path/to/your/file.txt | ||
rename branch | |||
git branch -m new-name | |||
git push origin :old-name new-name | |||
git push origin -u new-name | |||
remove without delete | |||
git rm --cached somefile.txt | |||
rebase history | |||
git rebase -i HEAD~3 | |||
in rebase, take theirs | |||
git checkout --theirs [file] | |||
"theirs" is a special flag during a rebase (check this, after I made the note, it looks like it didn't work). | |||
Unstage | |||
git reset | |||
Change origin | |||
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git | |||
== Grep == | |||
grep -lr --include \*.[EXT] --exclude \*[TAIL] "[SEARCH1]" ./ | xargs grep -n [SEARCH2] | |||
== Bash == | |||
Kill by port | |||
lsof -i tcp:${PORT_NUMBER} | awk 'NR!=1 {print $2}' | xargs kill | |||
lsof -i tcp:8080 | awk 'NR!=1 {print $2}' | xargs kill | |||
To create or update a symlink | |||
ln -sf /path/to/file /path/to/symlink | |||
New or attach | |||
screen -r | |||
Detach | |||
Ctrl+a,d | |||
Latest revision as of 13:36, 24 June 2018
Git
undo commit
$ git commit -m "Something terribly misguided" $ git reset HEAD~ << edit files as necessary >> $ git add ... $ git commit -c ORIG_HEAD
find in history
git log -S'the line from your file' -- path/to/your/file.txt
rename branch
git branch -m new-name git push origin :old-name new-name git push origin -u new-name
remove without delete
git rm --cached somefile.txt
rebase history
git rebase -i HEAD~3
in rebase, take theirs
git checkout --theirs [file]
"theirs" is a special flag during a rebase (check this, after I made the note, it looks like it didn't work).
Unstage
git reset
Change origin
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
Grep
grep -lr --include \*.[EXT] --exclude \*[TAIL] "[SEARCH1]" ./ | xargs grep -n [SEARCH2]
Bash
Kill by port
lsof -i tcp:${PORT_NUMBER} | awk 'NR!=1 {print $2}' | xargs kill
lsof -i tcp:8080 | awk 'NR!=1 {print $2}' | xargs kill
To create or update a symlink
ln -sf /path/to/file /path/to/symlink
New or attach
screen -r
Detach
Ctrl+a,d