Skip to content

Latest commit

ย 

History

History
1031 lines (686 loc) ยท 38.6 KB

README.ko.md

File metadata and controls

1031 lines (686 loc) ยท 38.6 KB

๊นƒํ—ˆ๋ธŒ ์น˜ํŠธ ์‹œํŠธ Awesome

A collection of cool hidden and not so hidden features of Git and GitHub. This cheat sheet was inspired by Zach Holman's Git and GitHub Secrets talk at Aloha Ruby Conference 2012 (slides) and his More Git and GitHub Secrets talk at WDCNZ 2013 (slides).

Shortlink: http://git.io/sheet

Read this in other languages: English, ํ•œ๊ตญ์–ด, ๆ—ฅๆœฌ่ชž, ็ฎ€ไฝ“ไธญๆ–‡, ๆญฃ้ซ”ไธญๆ–‡.

๋ชฉ๋ก

GitHub

Ignore Whitespace

?w=1๋ฅผ diff URL์— ์ถ”๊ฐ€ํ•˜๋ฉด ๋ณ€๊ฒฝ๋œ ์ฝ”๋“œ๋งŒ ๋ณผ ์ˆ˜ ์žˆ๋„๋ก, ๊ณต๋ฐฑ๋งŒ ๋ฐ”๋€ ์ˆ˜์ •์„ ์ œ๊ฑฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Diff without whitespace

๊นƒํ—ˆ๋ธŒ์˜ ๋น„๋ฐ€์„ ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Adjust Tab Space

diff๋‚˜ ํŒŒ์ผ URL์— ?ts=4๋ฅผ ๋ง๋ถ™์ด๋ฉด ํ… ๋ฌธ์ž์˜ ํฌ๊ธฐ๋ฅผ ๊ธฐ๋ณธ๊ฐ’์ธ 8๋Œ€์‹  4๊ณต๋ฐฑ์œผ๋กœ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค. ts๋’ค์˜ ์ˆซ์ž๋Š” ์„ค์ •์— ๋งž๊ฒŒ ๋ณ€๊ฒฝ ํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. gist๋‚˜ rawํŒŒ์ผ ๋ณด๊ธฐ์—๋Š” ์ ์šฉ ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค๋งŒ, ํฌ๋กฌ ์ต์Šคํ…์…˜์ด๋‚˜ ์˜คํŽ˜๋ผ ์ต์Šคํ…์…˜์œผ๋กœ ์ž๋™ํ™” ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์—ฌ๊ธฐ์— ์žˆ๋Š” Go ์†Œ์Šค ํŒŒ์ผ์€ ?ts=4๋ฅผ ๋ถ™์ด๊ธฐ ์ „์—๋Š” ์ด๋ ‡์Šต๋‹ˆ๋‹ค.

Before, tab space example

๊ทธ๋ฆฌ๊ณ  ?ts=4๋ฅผ ๋ถ™์ธ ๋‹ค์Œ์—๋Š” ์ด๋ ‡๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. --allow-empty After, tab space example

Commit History by Author

ํŠน์ • ์ปค๋ฏธํ„ฐ๊ฐ€ ํ•œ ๋ชจ๋“  ์ปค๋ฐ‹์„ ๋ณด๊ณ  ์‹ถ๋‹ค๋ฉด URL์— ?author={user}๋ฅผ ์ถ”๊ฐ€ํ•˜์„ธ์š”.

https://github.com/rails/rails/commits/master?author=dhh

DHH commit history

์ปค๋ฐ‹ ๋ทฐ๊ฐ„์˜ ์ฐจ์ด์— ๋Œ€ํ•ด ๋” ์ฝ์–ด๋ณด์„ธ์š”.

Cloning a Repository

์ €์žฅ์†Œ๋ฅผ ํด๋ก ํ•  ๋•Œ, ๋งจ ๋’ค์˜ .git์€ ์ƒ๋žตํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ git clone https://github.com/tiimgreen/github-cheat-sheet

๊นƒ clone ์ปค๋งจ๋“œ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

###Branch

Compare all Branches to Another Branch

์ €์žฅ์†Œ์˜ ๋ธŒ๋žœ์น˜ ํŽ˜์ด์ง€๋Š”, ์ปค๋ฐ‹ ๋ฒ„ํŠผ์˜ ๋’ค์— ์žˆ์Šต๋‹ˆ๋‹ค.

https://github.com/{user}/{repo}/branches

... ๋ฉ”์ธ ๋ธŒ๋žœ์น˜์— ๋จธ์ง€๋˜์ง€ ์•Š์€ ๋ชจ๋“  ๋ธŒ๋žœ์น˜์˜ ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์—ฌ๊ธฐ์—์„œ ๋ฒ„ํŠผ ํด๋ฆญ์œผ๋กœ ๋น„๊ต ํŽ˜์ด์ง€๋‚˜ ๋ธŒ๋žœ์น˜ ์‚ญ์ œ๋ฅผ ํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Compare branches not merged into master in rails/rails repo - https://github.com/rails/rails/branches

Comparing Branches

๊นƒํ—ˆ๋ธŒ์—์„œ ๋ธŒ๋žœ์น˜ ๋น„๊ต๋ฅผ ํ•˜์‹œ๋ ค๋ฉด, URL์„ ์ด๋Ÿฐ ์‹์œผ๋กœ ๋ฐ”๊พธ์„ธ์š”.

https://github.com/{user}/{repo}/compare/{range}

{range}๋Š” master...4-1-stable์‹์œผ๋กœ ์ ์Šต๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด

https://github.com/rails/rails/compare/master...4-1-stable

Rails branch compare example

{range} ๋Š” ์ด๋ ‡๊ฒŒ ์ ์„ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

https://github.com/rails/rails/compare/master@{1.day.ago}...master
https://github.com/rails/rails/compare/master@{2014-10-04}...master

๋‚ ์งœ๋Š” YYYY-MM-DDํ˜•์‹์œผ๋กœ ์ ์Šต๋‹ˆ๋‹ค

Another compare example

๋ธŒ๋žœ์น˜๋Š” diff๋‚˜ patch๋ทฐ๋กœ๋„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

https://github.com/rails/rails/compare/master...4-1-stable.diff
https://github.com/rails/rails/compare/master...4-1-stable.patch

์‹œ๊ฐ„์œผ๋กœ ์ปค๋ฐ‹์„ ๋น„๊ตํ•˜๋Š” ๋ฒ•์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Compare branches across forked repositories

ํฌํฌ๋œ ์ €์žฅ์†Œ๊ฐ„์˜ ๋ธŒ๋žœ์น˜๋ฅผ ๋น„๊ตํ•˜๋ ค๋ฉด URL์„ ์ด๋ ‡๊ฒŒ ๋ณ€๊ฒฝํ•˜์„ธ์š”.

https://github.com/{user}/{repo}/compare/{foreign-user}:{branch}...{own-branch}

์˜ˆ๋ฅผ ๋“ค๋ฉด

https://github.com/rails/rails/compare/byroot:idempotent-counter-caches...master

Forked branch compare

Gists

Gists๋Š” ๋ณธ๊ฒฉ์ ์ธ ์ €์žฅ์†Œ๋ฅผ ๋งŒ๋“ค์ง€ ์•Š๊ณ , ์ž‘์€ ์ฝ”๋“œ ์กฐ๊ฐ๊ณผ ์ผํ•  ์ˆ˜ ์žˆ๋Š” ์‰ฌ์šด ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.

Gist

์ด๋ ‡๊ฒŒ Gist URL๋’ค์— .pibb๋ฅผ ๋„ฃ์œผ๋ฉด ๋‹ค๋ฅธ ์‚ฌ์ดํŠธ์— ๋„ฃ์„์ˆ˜ ์žˆ๋Š” HTML ์˜จ๋ฆฌ ๋ฒ„์ „์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Gists๋Š” ์ €์žฅ์†Œ์ฒ˜๋Ÿผ ์ทจ๊ธ‰ํ•  ์ˆ˜ ์žˆ๊ณ  ํด๋ก ๋„ ๋ฉ๋‹ˆ๋‹ค.

$ git clone https://gist.github.com/tiimgreen/10545817

Gists

์ด๋Š” Gists์—์„œ๋„ ์ˆ˜์ •ํ•˜๊ณ  ์—…๋ฐ์ดํŠธ๋ฅผ ํ‘ธ์‰ฌํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ์˜๋ฏธ์ž…๋‹ˆ๋‹ค.

$ git commit
Username for 'https://gist.github.com':
Password for 'https://[email protected]':

ํ•˜์ง€๋งŒ, Gists๋Š” ๋””๋ž™ํ† ๋ฆฌ๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋ชจ๋“  ํŒŒ์ผ์€ ์ €์žฅ์†Œ์˜ ๋ฃจํŠธ์— ๋„ฃ์„ ํ•„์š”๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. Gist๋ฅผ ๋งŒ๋“œ๋Š” ๋ฒ•์— ๋Œ€ํ•ด ๋” ์ฝ์–ด๋ณด์„ธ์š”.

Git.io

Git.io๋Š” ๊นƒํ—ˆ๋ธŒ๋ฅผ ์œ„ํ•œ ๊ฐ„๋‹จํ•œ URL ๋‹จ์ถ•๊ธฐ์ž…๋‹ˆ๋‹ค.

Git.io

์ˆœ์ˆ˜ HTTP์—์„œ Curl์œผ๋กœ ์‚ฌ์šฉํ•˜์‹ค ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

$ curl -i http://git.io -F "url=https://github.com/..."
HTTP/1.1 201 Created
Location: http://git.io/abc123

$ curl -i http://git.io/abc123
HTTP/1.1 302 Found
Location: https://github.com/...

Git.io์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Keyboard Shortcuts

์ €์žฅ์†Œ ํŽ˜์ด์ง€์—์„œ ๋‹จ์ถ•ํ‚ค๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์‰ฝ๊ฒŒ ์ด๋™ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • t๋ฅผ ๋ˆ„๋ฅด๋ฉด ํŒŒ์ผ ํƒ์ƒ‰ ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.
  • w๋ฅผ ๋ˆ„๋ฅด๋ฉด ๋ธŒ๋ Œ์น˜ ์„ ํƒ ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค.
  • s๋ฅผ ๋ˆ„๋ฅด๋ฉด ์ง€๊ธˆ ์ €์žฅ์†Œ์˜ ๊ฒ€์ƒ‰์ฐฝ์ด ํฌ์ปค์Šค๋ฉ๋‹ˆ๋‹ค. ๋ฐฑ์ŠคํŽ˜์ด์Šค๋ฅผ ๋ˆ„๋ฅด๋ฉด ์ฑ„์›Œ์ ธ ์žˆ๋Š” "This repository"๋ฅผ ์ง€์›Œ GitHub์ „์ฒด์—์„œ ๊ฒ€์ƒ‰ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
  • l๋ฅผ ๋ˆ„๋ฅด๋ฉด ์žˆ๋Š” ์ด์Šˆ์˜ ๋ผ๋ฒจ์„ ์ˆ˜์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ํŒŒ์ผ์„ ๋ณด๊ณ  ์žˆ์„ ๋•Œ (์˜ˆ๋ฅผ ๋“ค์–ด https://github.com/tiimgreen/github-cheat-sheet/blob/master/README.md) y๋ฅผ ๋ˆ„๋ฅด๋ฉด URL์„ ์ง€๊ธˆ ๋ณด๊ณ  ์žˆ๋Š” ํŽ˜์ด์ง€๋ฅผ ์‚ฌ์‹ค์ƒ ๊ณ ์ •ํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. ์ฝ”๋“œ๊ฐ€ ๋ฐ”๋€๋‹ค๊ณ  ํ•ด๋„ ์ด๋ฒˆ์— ๋ณธ ๋‚ด์šฉ์„ ๋‹ค์‹œ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ง€๊ธˆ ํŽ˜์ด์ง€์—์„œ ์“ธ ์ˆ˜ ์žˆ๋Š” ๋ชจ๋“  ๋‹จ์ถ•ํ‚ค๋ฅผ ๋ณด์‹œ๋ ค๋ฉด ?๋ฅผ ๋ˆ„๋ฅด์„ธ์š”.

Keyboard shortcuts

์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒ€์ƒ‰ ๋ฌธ๋ฒ•์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Line Highlighting in Repos

์ฝ”๋“œ ํŒŒ์ผ URL์˜ ๋์— #L52๋ฅผ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ์ค„ ๋ฒˆํ˜ธ๋ฅผ ํด๋ฆญํ•˜๋ฉด ๊ทธ ์ค„ ๋ฒˆํ˜ธ๋ฅผ ํ•˜์ด๋ผ์ดํŠธํ•ฉ๋‹ˆ๋‹ค.

#L53-L60์ฒ˜๋Ÿผ ๋ฒ”์œ„์ง€์ •๋„ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ๋ฒ”์œ„๋ฅผ ์ง€์ •ํ•˜๋ ค๋ฉด shiftํ‚ค๋ฅผ ๋ˆ„๋ฅธ ์ฑ„ ๋‘ ๋ผ์ธ์„ ํด๋ฆญํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

https://github.com/rails/rails/blob/master/activemodel/lib/active_model.rb#L53-L60

Line Highlighting

Closing Issues with Commits

์–ด๋–ค ์ปค๋ฐ‹์ด ์ด์Šˆ๋ฅผ ๊ณ ์ณค๋‹ค๋ฉด, fix/fixes/fixed, close/closes/closed, resolve/resolves/resolved๋ฅผ ํ‚ค์›Œ๋“œ๋กœ ํ•ด๋‹น ์ด์Šˆ๊ฐ€ ๋งˆ์Šคํ„ฐ ๋ธŒ๋žœ์น˜์— ์ปค๋ฐ‹ ๋  ๋•Œ ๋‹ซ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ git commit -m "Fix screwup, fixes #12"

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์ด์Šˆ๋ฅผ ๋‹ซ๊ณ  ํด๋กœ์ง• ์ปค๋งจํŠธ๋กœ ์ฐธ์กฐํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

Closing Repo

์ปค๋ฐ‹ ๋ฉ”์„ธ์ง€๋กœ ์ด์Šˆ ๋‹ซ๊ธฐ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Cross-Link Issues

๊ฐ™์€ ์ €์žฅ์†Œ์˜ ๋‹ค๋ฅธ ์ด์Šˆ๋ฅผ ๋งํฌํ•˜๊ธฐ ์›ํ•œ๋‹ค๋ฉด, #๋’ค์— ์ด์Šˆ ๋ฒˆํ˜ธ๋งŒ ์ž…๋ ฅํ•˜์‹œ๋ฉด ์ž๋™์œผ๋กœ ๋งํฌ๋ฉ๋‹ˆ๋‹ค.

๋‹ค๋ฅธ ์ €์žฅ์†Œ์˜ ์ด์Šˆ๋ฅผ ๋งํฌํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด {user}/{repo}#์ด์Šˆ_๋ฒˆํ˜ธ๋กœ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. (์˜ˆ tiimgreen/toc#12)

Cross-Link Issues

Locking Conversations

ํ’€ ๋ฆฌํ€˜์ŠคํŠธ์™€ ์ด์Šˆ๋Š” ๋ ˆํฌ์ง€ํ„ฐ๋ฆฌ์˜ ์ฃผ์ธ์ด๋‚˜ ํ˜‘์—…์ž์— ์˜ํ•ด ์ž ๊ธ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Lock conversation

์ด๋Š” ํ”„๋กœ์ ํŠธ์˜ ํ˜‘์—…์ž๊ฐ€ ์•„๋‹Œ ์‚ฌ๋žŒ์€ ๋” ์ด์ƒ ์ปค๋งจํŠธ๋ฅผ ๋‹ฌ ์ˆ˜ ์—†๊ฒŒ๋œ๋‹ค๋Š” ๋ง์ž…๋‹ˆ๋‹ค.

Comments locked

๋Œ€ํ™” ์ž ๊ทธ๊ธฐ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

CI Status on Pull Requests

์ •ํ™•ํžˆ ์„ค์ •๋˜์—ˆ๋‹ค๋ฉด, ํ’€ ๋ฆฌํ€˜์ŠคํŠธ๋ฅผ ๋ฐ›๊ฑฐ๋‚˜ ํ’€ ๋ฆฌํ€˜์ŠคํŠธ์— ์ƒˆ๋กœ์šด ์ปค๋ฐ‹์„ ํ•  ๋•Œ ๋งˆ๋‹ค, Travis CI๊ฐ€ ํ’€ ๋ฆฌํ€˜์ŠคํŠธ๋ฅผ ๋นŒ๋“œ ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค. Travis CI ์‹œ์ž‘ํ•˜๊ธฐ๋ฅผ ์ข€ ๋” ์ฝ์–ด๋ณด์„ธ์š”.

Travis CI status

์ปค๋ฐ‹ ์ƒํƒœ API์— ๋Œ€ํ•ด ์ข€ ๋” ์ฝ์–ด๋ณด์„ธ์š”.

Syntax Highlighting in Markdown Files

๋งˆํฌ๋‹ค์šด์—์„œ ์˜ˆ๋ฅผ ๋“ค์–ด, ๋ฃจ๋น„ ์ฝ”๋“œ๋ฅผ ์‹ ํ…์Šค ํ•˜์ด๋ผ์ดํŠธ ํ•˜๋ ค๋ฉด ์ด๋ ‡๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

```ruby
require 'tabbit'
table = Tabbit.new('Name', 'Email')
table.add_row('Tim Green', '[email protected]')
puts table.to_s
```

์ด๋ ‡๊ฒŒ ๋ณด์ž…๋‹ˆ๋‹ค.

require 'tabbit'
table = Tabbit.new('Name', 'Email')
table.add_row('Tim Green', '[email protected]')
puts table.to_s

๊นƒํ—ˆ๋ธŒ๋Š” Linguist๋ฅผ ์‚ฌ์šฉํ•ด ์–ธ์–ด๋ฅผ ๊ฐ์ง€ํ•˜๊ณ  ์‹ ํ…์Šค๋ฅผ ํ•˜์ด๋ผ์ดํŠธํ•ฉ๋‹ˆ๋‹ค. ์–ธ์–ด YAML ํŒŒ์ผ์„ ์ •๋…ํ•˜์‹œ๋ฉด ์–ด๋–ค ํ‚ค์›Œ๋“œ๊ฐ€ ์œ ํšจํ•œ์ง€ ํ™•์ธํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๊นƒํ—ˆ๋ธŒ Flavored ๋งˆํฌ๋‹ค์šด์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Emojis

์—๋ชจ์ง€๋Š” ํ’€ ๋ฆฌํ€˜์ŠคํŠธ, ์ด์Šˆ, ์ปค๋ฐ‹ ๋ฉ”์„ธ์ง€, ์ €์žฅ์†Œ ์„ค๋ช…๋“ฑ์— :์—๋ชจ์ง€์˜_์ด๋ฆ„:์œผ๋กœ ๋„ฃ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๊นƒํ—ˆ๋ธŒ์—์„œ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์—๋ชจ์ง€์˜ ์ „ ๋ชฉ๋ก์€ emoji-cheat-sheet.com ๋‚˜ scotch-io/All-Github-Emoji-Icons์—์„œ ํ™•์ธํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๊นƒํ—ˆ๋ธŒ์—์„œ ๋งŽ์ด ์‚ฌ์šฉํ•˜๋Š” ์—๋ชจ์ง€ ํƒ‘ 5์œ„๋Š” ์ด๋ ‡์Šต๋‹ˆ๋‹ค.

  1. :shipit:
  2. :sparkles:
  3. :-1:
  4. :+1:
  5. :clap:

Images/GIFs

์ปค๋งจํŠธ๋‚˜ README๋“ฑ๋“ฑ์— ์ด๋ฏธ์ง€์™€ GIF๋ฅผ ๋„ฃ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

![Alt Text](http://www.sheawong.com/wp-content/uploads/2013/08/keephatin.gif)

์ €์žฅ์†Œ์— ์žˆ๋Š” ์ด๋ฏธ์ง€๋Š” ์ง์ ‘ ๋ถˆ๋Ÿฌ์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

![Alt Text](https://github.com/{user}/{repo}/raw/master/path/to/image.gif)

Peter don't care

๋ชจ๋“  ์ด๋ฏธ์ง€๋Š” GitHub์—์„œ ์ผ€์‰ฌํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ํ˜ธ์ŠคํŠธ๊ฐ€ ์ฃฝ์–ด๋„ ์ด๋ฏธ์ง€๋Š” ์—ฌ์ „ํžˆ ๋‚จ์Šต๋‹ˆ๋‹ค.

Embedding Images in GitHub Wiki

์ด๋ฏธ์ง€๋ฅผ ์œ„ํ‚ค ํŽ˜์ด์ง€์—๋„ฃ๋Š” ๋ฐฉ๋ฒ•์€ ์—ฌ๋Ÿฟ ์žˆ์Šต๋‹ˆ๋‹ค. ์œ„์— ๋ณด์ด๋Š” ์ผ๋ฐ˜ ๋งˆํฌ๋‹ค์šด ๋ฌธ๋ฒ•๋„ ์žˆ์ง€๋งŒ, ์ด๋ฏธ์ง€์— ๋†’์ด์™€ ๋„“์ด๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฌธ๋ฒ•๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

[[ http://www.sheawong.com/wp-content/uploads/2013/08/keephatin.gif | height = 100px ]]

์ด๋ ‡๊ฒŒ ๋ณด์ž…๋‹ˆ๋‹ค.

Just a screenshot

Quick Quoting

์Šค๋ ˆ๋“œ์— ๋‹ต๊ธ€๋“ค ๋•Œ ์ „์— ๋ˆ„๊ฐ€ ๋งํ•œ ์–ด๋–ค ๋‚ด์šฉ์„ ์ธ์šฉํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, ํ…์ŠคํŠธ๋ฅผ ํ•˜์ด๋ผ์ดํŠธํ•˜๊ณ  r์„ ๋ˆ„๋ฅด์„ธ์š”. ์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋‚ด์šฉ์„ ํ…์ŠคํŠธ ๋ฐ•์Šค์— ์ธ์šฉ ํฌ๋งท์œผ๋กœ ๋ณต์‚ฌํ•ด ์ค๋‹ˆ๋‹ค.

Quick Quote

๋น ๋ฅธ ์ธ์šฉ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Pasting Clipboard Image to Comments

(ํฌ๋กฌ์—์„œ๋งŒ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค)

์Šคํฌ๋ฆฐ์ƒท์„ ์ฐ๊ณ  ํด๋ฆฝ๋ณด๋“œ์— ์žˆ๋Š” ๊ฒฝ์šฐ (mac: cmd-ctrl-shift-4), ๊ฐ„๋‹จํžˆ ์ด๋ฏธ์ง€๋ฅผ ์ปค๋งจํŠธ ์ƒ‰์…˜์— ๋ถ™์—ฌ๋„ฃ๊ธฐ(cmd-v / ctrl-v)ํ•  ์ˆ˜ ์žˆ๊ณ  ์ด๋Š” ์ž๋™์œผ๋กœ ๊นƒํ—ˆ๋ธŒ์— ์—…๋กœ๋“œ ๋ฉ๋‹ˆ๋‹ค.

Pasting Clipboard Image to Comments

issue attachments์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Quick Licensing

์ €์žฅ์†Œ๋ฅผ ๋งŒ๋“ค ๋•Œ, ๊นƒํ—ˆ๋ธŒ๋Š” ๋งŒ๋“ค์–ด์ง„ ์ €์ž‘๊ถŒ์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ๋Š” ์˜ต์…˜์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

License

์ด๋ฏธ ์žˆ๋Š” ์ €์žฅ์†Œ์—๋„ ์›น ์ธํ„ฐํŽ˜์ด์Šค์—์„œ ์ƒˆ ํŒŒ์ผ์„ ๋งŒ๋“ค์–ด ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฆ„์— LICENSE๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์˜ต์…˜์œผ๋กœ ํ…œํ”Œ๋ฆฟ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

License

.gitignore์—๋„ ๋˜‘๊ฐ™์ด ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.

์˜คํ”ˆ ์†Œ์Šค ์ €์ž‘๊ถŒ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Task Lists

์ด์Šˆ์™€ ํ’€ ๋ฆฌํ€˜์ŠคํŠธ์—์„œ ๋ฐ‘์˜ ๋ฌธ๋ฒ•์œผ๋กœ ์ฒดํฌ๋ฐ•์Šค๋ฅผ ๋„ฃ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.(์ŠคํŽ˜์ด์Šค์— ์ฃผ์˜ํ•˜์„ธ์š”.)

- [ ] Be awesome
- [ ] Prepare dinner
  - [ ] Research recipe
  - [ ] Buy ingredients
  - [ ] Cook recipe
- [ ] Sleep

Task List

์ฒดํฌ๋ฐ•์Šค๊ฐ€ ํด๋ฆญ ๋˜๋ฉด, ์ˆœ์ˆ˜ ๋งˆํฌ๋‹ค์šด์—์„œ ๊ฐฑ์‹ ์ด ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค.

- [x] Be awesome
- [ ] Prepare dinner
  - [x] Research recipe
  - [x] Buy ingredients
  - [ ] Cook recipe
- [ ] Sleep

ํ…Œ์Šคํฌ ๋ฆฌ์ŠคํŠธ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Task Lists in Markdown Documents

์ด์ œ ๋งˆํฌ๋‹ค์šด ๋ฌธ์„œ์—์„œ ์ฝ๊ธฐ ์ „์šฉ ์ฒดํฌ๋ฆฌ์ŠคํŠธ๋ฅผ ๋„ฃ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

- [ ] Mercury
- [x] Venus
- [x] Earth
- [x] Mars
- [ ] Jupiter
  • Mercury
  • Venus
  • Earth
  • Mars
  • Jupiter

๋งˆํฌ๋‹ค์šด ๋ฌธ์„œ์—์„œ์˜ ํ…Œ์Šคํฌ ๋ฆฌ์ŠคํŠธ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Relative Links

์ƒ๋Œ€ ๊ฒฝ๋กœ ๋งํฌ๋Š” ๋งˆํฌ๋‹ค์šด ํŒŒ์ผ์ด ๋‚ด๋ถ€ ์ปจํ…์ธ ๋กœ ๋งํฌ๋  ๋•Œ ์ถ”์ฒœํ•ฉ๋‹ˆ๋‹ค.

[Link to a header](#awesome-section)

[Link to a file](docs/readme)

์ ˆ๋Œ€ ๊ฒฝ๋กœ ๋งํฌ๋Š” URL์ด ๋ณ€๊ฒฝ ๋  ๋•Œ ๋งˆ๋‹ค ๋ณ€๊ฒฝํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. (์˜ˆ๋ฅผ ๋“ค์–ด ์ €์žฅ์†Œ ์ด๋ฆ„ ๋ณ€๊ฒฝ, ์œ ์ €์ด๋ฆ„ ๋ณ€๊ฒฝ, ํ”„๋กœ์ ํŠธ ํฌํฌ) ์ƒ๋Œ€ ๊ฒฝ๋กœ ๋งํฌ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋ฌธ์„œ๋ฅผ ์‰ฝ๊ฒŒ ์Šค์Šค๋กœ ๋…๋ฆฝ์ ์œผ๋กœ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ƒ๋Œ€ ๊ฒฝ๋กœ ๋งํฌ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Metadata and Plugin Support for GitHub Pages

์ง€ํ‚ฌ๋กœ ์ž‘์„ฑ๋œ ํŽ˜์ด์ง€์™€ ํฌ์ŠคํŠธ์—์„œ, ์ €์žฅ์†Œ ์ •๋ณด๋Š” ์˜ˆ๋ฅผ ๋“ค์–ด {{ site.github.project_title }}์ฒ˜๋Ÿผ site.github ์ด๋ฆ„ ๊ณต๊ฐ„์œผ๋กœ ์‚ฌ์šฉํ•˜๊ณ  ํ‘œ์‹œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Jemoji์™€ jekyll-mentionsํ”Œ๋Ÿฌ๊ทธ์ธ์€ GitHub.com์—์„œ ์ฒ˜๋Ÿผ emoji์™€ @mentions์„ ์ง€ํ‚ฌ ํฌ์ŠคํŠธ์™€ ํŽ˜์ด์ง€์—์„œ ์‚ฌ์šฉํ•˜๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

์ €์žฅ์†Œ ๋ฉ”ํƒ€ ๋ฐ์ดํƒ€์™€ ๊นƒํ—ˆ๋ธŒ ํŽ˜์ด์ง€์˜ ํ”Œ๋Ÿฌ๊ทธ์ธ ์ง€์›์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Viewing YAML Metadata in your Documents

Jekyll์ด๋‚˜ GitHub Pages๊ฐ™์€ ๋งŽ์€ ๋ธ”๋กœ๊ทธ์—์„œ ํฌ์ŠคํŠธ์˜ ์ฒ˜์Œ์— YAML ํฌ๋ฉง์˜ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ๋ฅผ ํ•„์š”๋กœ ํ•ฉ๋‹ˆ๋‹ค. ๊นƒํ—ˆ๋ธŒ๋Š” ์ด ๋ฉ”ํƒ€ ์ •๋ณด๋ฅผ ์ฝ๊ธฐ ํŽธํ•˜๊ฒŒ ํ…Œ์ด๋ธ”๋กœ ํ‘œ์‹œํ•ด ์ค๋‹ˆ๋‹ค.

YAML metadata

๋ฌธ์„œ์—์„œ YAML ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๋ณด๊ธฐ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Rendering Tabular Data

๊นƒํ—ˆ๋ธŒ๋Š” .csv (comma-separated) ์™€ .tsv (tab-separated)ํŒŒ์ผ์— ๋Œ€ํ•ด ํ‘œ(tabular) ๋ฐ์ดํ„ฐ ๋ณด๊ธฐ๋ฅผ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.

Tabular data

ํ‘œ ๋ฐ์ดํƒ€ ํ‘œ์‹œ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Rendering PDF

๊นƒํ—ˆ๋ธŒ์—์„œ PDF๋ฅผ ๋ Œ๋”๋งํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

PDF

PDF ๋ Œ๋”๋ง์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Revert a Pull Request

ํ’€ ๋ฆฌํ€˜์ŠคํŠธ๊ฐ€ ๋จธ์ง€๋œ ํ›„์—, ์•„๋ฌด ๋„์›€์ด ์•ˆ๋˜๊ฑฐ๋‚˜ ๋จธ์ง€๊ฐ€ ์ž˜๋ชป๋œ ๊ฒฐ์ •์ด์—ˆ๋‹ค๋Š” ๊ฑธ ๋ˆˆ์น˜ ์ฑŒ ๋•Œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ’€ ๋ฆฌํ€˜์ŠคํŠธ ํŽ˜์ด์ง€์˜ ์ปค๋ฐ‹์˜ ์˜ค๋ฅธ ์ชฝ์— ์žˆ๋Š” Revert ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด ์ด ํ’€๋ฆฌํ€˜์ŠคํŠธ๋ฅผ ๋˜๋Œ๋ฆฌ๋Š” ํ’€๋ฆฌํ€˜์ŠคํŠธ๋ฅผ ๋งŒ๋“ค์–ด ๋˜๋Œ๋ฆด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Revert button

ํ’€ ๋ฆฌํ€˜์ŠคํŠธ ๋˜๋Œ๋ฆฌ๊ธฐ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Diffs

Rendered Prose Diffs

GitHub์—์„œ ์ง€์›ํ•˜๋Š” ์‚ฐ๋ฌธ(prose) ํŒŒ์ผ(์˜ˆ๋ฅผ ๋“ค์–ด Markdown)์ด ์žˆ๋Š” ์ปค๋ฐ‹๊ณผ ํ’€ ๋ฆฌํ€˜์ŠคํŠธ์—์„œ๋Š” source์™€ rendered ๋ทฐ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Source / Rendered view

"rendered" ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜์‹œ๋ฉด ๋ Œ๋”๋œ ๋ฌธ์„œ์—์„œ ๋ณ€๊ฒฝ์„ ํ™•์ธํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ Œ๋”๋œ ์‚ฐ๋ฌธ(prose) ๋ทฐ๋Š” ๋ฌธ์žฅ์„ ์ถ”๊ฐ€, ์‚ญ์ œ, ๋ณ€๊ฒฝํ–ˆ์„๋•Œ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.

Rendered Prose Diffs

๋ Œ๋”๋œ ์‚ฐ๋ฌธ(prose) diff์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Diffable Maps

์ง€์˜ค๋ฐ์ดํƒ€๊ฐ€ ํฌํ•จ๋œ ์ปค๋ฐ‹์ด๋‚˜ ํ’€ ๋ฆฌํ€˜์ŠคํŠธ๋ฅผ ๋ณผ ๋•Œ๋งˆ๋‹ค ๊นƒํ—ˆ๋ธŒ๋Š” ๋ฌด์—‡์ด ๋ณ€๊ฒฝ ๋˜์—ˆ๋Š”์ง€ ์‹œ๊ฐ์ ์œผ๋กœ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

Diffable Maps

diff ๊ฐ€๋Šฅํ•œ ๋งต์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Expanding Context in Diffs

diff์˜ ๋‹ซ์•„๋‘” ๊ณณ์˜ ํŽผ์นจ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด, ๋ฌธ๋งฅ์„ ๋” ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ „์ฑ„ ํŒŒ์ผ์„ ํ‘œ์‹œํ• ๋•Œ๊นŒ์ง€ ๊ณ„์† ํŽผ์น  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ๊นƒํ—ˆ๋ธŒ์—์„œ diff๊ฐ€ ํ‘œ์‹œ๋˜๋Š” ์žฅ์†Œ๋ผ๋ฉด ์–ด๋””์„œ๋“  ์‚ฌ์šฉ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

Expanding Context in Diffs

diff์—์„œ์˜ ๋ฌธ๋งฅ ํ™•์žฅ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Diff or Patch of Pull Request

URL๋’ค์— .diff ๋‚˜ .patch๋ฅผ ๋ถ™์ด๋ฉด ํ’€ ๋ฆฌํ€˜์ŠคํŠธ์˜ diff๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด

https://github.com/tiimgreen/github-cheat-sheet/pull/15
https://github.com/tiimgreen/github-cheat-sheet/pull/15.diff
https://github.com/tiimgreen/github-cheat-sheet/pull/15.patch

.diff ํ™•์žฅ์ž๋Š” ์ด๋Ÿฐ ๋‚ด์šฉ์˜ ํ‰๋ฒ”ํ•œ(plain) ํ…์ŠคํŠธ๋ฅผ ์ค๋‹ˆ๋‹ค.

diff --git a/README.md b/README.md
index 88fcf69..8614873 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,7 @@ All the hidden and not hidden features of Git and GitHub. This cheat sheet was i
 - [Merged Branches](#merged-branches)
 - [Quick Licensing](#quick-licensing)
 - [TODO Lists](#todo-lists)
+- [Relative Links](#relative-links)
 - [.gitconfig Recommendations](#gitconfig-recommendations)
     - [Aliases](#aliases)
     - [Auto-correct](#auto-correct)
@@ -381,6 +382,19 @@ When they are clicked, they will be updated in the pure Markdown:
 - [ ] Sleep

(...)

Rendering and diffing images

๊นƒํ—ˆ๋ธŒ๋Š” PNG, JPG, GIF, PSD๋ฅผ ํฌํ•จํ•œ ์—ฌ๋Ÿฌ ์ผ๋ฐ˜ ์ ์ธ ์ด๋ฏธ์ง€ ํ˜•์‹์„ ํ‘œ์‹œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ถ”๊ฐ€์ ์œผ๋กœ ์ด๋ฏธ์ง€ ํ˜•์‹์˜ diff๋ฅผ ํ‘œ์‹œํ•˜๋Š” ์—ฌ๋Ÿฌ ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

[Diffable PSD](https://github.com/blog/1845-psd-viewing-diffing

์ด๋ฏธ์ง€ diff์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Hub

Hub๋Š” ๊นƒํ—ˆ๋ธŒ๋ฅผ ์ข€ ๋” ์‰ฝ๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์ถ”๊ฐ€ ๊ธฐ๋Šฅ ๋ฐ ๋ช…๋ น์„ ์ œ๊ณตํ•˜๋Š” ์ปค๋งจ๋“œ ๋ผ์ธ ๊นƒ ๋ž˜ํผ์ž…๋‹ˆ๋‹ค.

์ด๋ ‡๊ฒŒ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ hub clone tiimgreen/toc

Hub๊ฐ€ ์ œ๊ณตํ•˜๋Š” ๋” ๋ฉ‹์ง„ ๊ธฐ๋Šฅ๋“ค์„ ํ™•์ธํ•ด ๋ณด์„ธ์š”.

Contributing Guidelines

์ €์žฅ์†Œ์˜ ์ œ์ผ ์œ„์— CONTRIBUTING ํŒŒ์ผ์„ ๋„ฃ์–ด๋‘๋ฉด ๊ธฐ์—ฌ์ž๊ฐ€ ์ด์Šˆ๋ฅผ ๋งŒ๋“ค๊ฑฐ๋‚˜ ํ’€ ๋ฆฌํ€˜์ŠคํŠธ๋ฅผ ๋งŒ๋“ค ๋•Œ ๋งํฌ๋กœ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

Contributing Guidelines

๊ธฐ์—ฌํ•˜๊ธฐ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Octicons

๊นƒํ—ˆ๋ธŒ ์•„์ด์ฝ˜(์˜ฅํ‹ฐ์ฝ˜)์ด ์ด์ œ ์˜คํ”ˆ์†Œ์Šค๊ฐ€ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

Octicons

๊นƒ ํ—ˆ๋ธŒ์˜ ์˜ฅํ‹ฐ์ฝ˜์— ๋Œ€ํ•ด ๋” ์ฝ์–ด๋ณด์„ธ์š”.

GitHub Resources

Title Link
GitHub Explore https://github.com/explore
GitHub Blog https://github.com/blog
GitHub Help https://help.github.com/
GitHub Training https://training.github.com/
GitHub Developer https://developer.github.com/

GitHub Talks

Title Link
How GitHub Uses GitHub to Build GitHub https://www.youtube.com/watch?v=qyz3jkOBbQY
Introduction to Git with Scott Chacon of GitHub https://www.youtube.com/watch?v=ZDR433b0HJY
How GitHub No Longer Works https://www.youtube.com/watch?v=gXD1ITW7iZI
Git and GitHub Secrets https://www.youtube.com/watch?v=Foz9yvMkvlA
More Git and GitHub Secrets https://www.youtube.com/watch?v=p50xsL-iVgU

Git

Remove All Deleted Files from the Working Tree

/bin/rm์„ ์‚ฌ์šฉํ•ด ๋Œ€๋Ÿ‰์˜ ํŒŒ์ผ์„ ์ง€์šธ ๋•Œ, ํ•˜๋‚˜์”ฉ ์ œ๊ฑฐํ•  ํ•„์š” ์—†์ด ๋ฐ‘์˜ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•ด ์ž‘์—… ๋””๋ ‰ํ„ฐ๋ฆฌ์™€ ์ธ๋ฑ์Šค์—์„œ ์ง€์šธ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ git rm $(git ls-files -d)

์˜ˆ๋ฅผ ๋“ค์–ด

$ git status
On branch master
Changes not staged for commit:
       deleted:    a
       deleted:    c

$ git rm $(git ls-files -d)
rm 'a'
rm 'c'

$ git status
On branch master
Changes to be committed:
       deleted:    a
       deleted:    c

Previous Branch

์ปค๋งจ๋“œ ๋ผ์ธ์—์„œ ์ด์ „ ๋””๋ ‰ํ„ฐ๋ฆฌ๋กœ ์ด๋™ํ•˜๋ ค๋ฉด ์ด๋ ‡๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

$ cd -

๋น„์Šทํ•˜๊ฒŒ, ๊นƒ์—์„œ ๋งˆ์ง€๋ง‰ ๋ธŒ๋žœ์น˜๋กœ ๋Œ์•„๊ฐ€๋Š” ๊ฑด ์ด๋ ‡๊ฒŒ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ git checkout -
# Switched to branch 'master'

$ git checkout -
# Switched to branch 'next'

$ git checkout -
# Switched to branch 'master'

๊นƒ ๋ธŒ๋žœ์น˜์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Stripspace

๊นƒ Stripspace๋Š” ์ด๋Ÿฐ ์ผ์„ ํ•ฉ๋‹ˆ๋‹ค.

  • ์ค„ ๋์˜ ๊ณต๋ฐฑ์„ ์ œ๊ฑฐ
  • ๋นˆ์ค„์„ ์ค„์ž„
  • ํŒŒ์ผ ๋์— ๋นˆ ์ค„์„ ์ถ”๊ฐ€

์ปค๋งจ๋“œ๋ฅผ ์‹คํ–‰ ํ•  ๋•Œ ํŒŒ์ผ์„ ๋ฐ˜๋“œ์‹œ ์ด๋Ÿฐ์‹์œผ๋กœ ๋„˜๊ฒจ์ค˜์•ผ ํ•ฉ๋‹ˆ๋‹ค.

$ git stripspace < README.md

๊นƒ stripspace ์ปค๋งจ๋“œ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

SSH keys

๋ฐ‘์˜ ์ฃผ์†Œ๋ฅผ ๋ฐฉ๋ฌธํ•˜๋ฉด ๊ณต๊ฐœ ssh ํ‚ค์˜ ๋ชฉ๋ก์„ ์ผ๋ฐ˜ ํ…์ŠคํŠธ ํ˜•์‹์œผ๋กœ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

https://github.com/{user}.keys

e.g. https://github.com/tiimgreen.keys

๊ณต๊ฐœ ssh ํ‚ค ์ ‘๊ทผ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Checking out Pull Requests

ํ’€ ๋ฆฌํ€˜์ŠคํŠธ๋Š” ๊นƒํ—ˆ๋ธŒ ์ €์žฅ์†Œ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ํŠน๋ณ„ํ•œ ๋ธŒ๋žœ์น˜๋กœ ์—ฌ๋Ÿฌ ๋ฐฉ๋ฒ•์œผ๋กœ ๋กœ์ปฌ๋กœ ๊ฐ€์ ธ ์˜ฌ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋น ๋ฅด๊ฒŒ diff๋‚˜ merge๋ฅผ ํ•˜๊ธฐ์œ„ํ•ด ํŠน์ • ํ’€ ๋ฆฌํ€˜์ŠคํŠธ๋ฅผ ์ž„์‹œ๋กœ FETCH_HEAD๋กœ ๊ฐ€์ ธ์˜ค๋ ค๋ฉด ์ด๋ ‡๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

$ git fetch origin refs/pull/[PR-Number]/head

๋ชจ๋“  ํ’€ ๋ฆฌํ€˜์ŠคํŠธ ๋ธŒ๋žœ์น˜๋ฅผ refspec์— ์˜ํ•œ ๋กœ์ปฌ ๋ฆฌ๋ชจํŠธ ๋ธŒ๋žœ์น˜๋กœ ๋ฐ›์„ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

$ git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*'

๋ฐ‘์˜ ์ค„๋“ค์„ ์ €์žฅ์†Œ์˜ .git/config์— ์ถ”๊ฐ€ํ•˜์—ฌ, ๋ฆฌ๋ชจํŠธ์˜ ํ’€ ๋ฆฌํ€˜์ŠคํŠธ๋ฅผ ์ž๋™์œผ๋กœ ๊ฐ€์ ธ์˜ค๊ฒŒ๋„ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = [email protected]:tiimgreen/github-cheat-sheet.git
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = [email protected]:tiimgreen/github-cheat-sheet.git
    fetch = +refs/pull/*/head:refs/remotes/origin/pr/*

ํฌํฌ ๊ธฐ๋ฐ˜์˜ ํ’€ ๋ฆฌํ€˜์ŠคํŠธ ๊ธฐ์—ฌ๋ฅผ ์œ„ํ•ด, ํ’€ ๋ฆฌํ€˜์ŠคํŠธ์˜ ๋ฆฌ๋ชจํŠธ ๋ธŒ๋žœ์น˜๋ฅผ checkoutํ•ด ๋กœ์ปฌ ๋ธŒ๋žœ์น˜๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒƒ์€ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.

$ git checkout pr/42 pr-42

์—ฌ๋Ÿฌ ์ €์žฅ์†Œ๋ฅผ ๋‹ค๋ฃจ์–ด์•ผ ํ•œ๋‹ค๋ฉด, ์ „์—ญ ๊นƒ ์„ค์ •์—์„œ ํ’€ ๋ฆฌํ€˜์ŠคํŠธ๋ฅผ ๋ฐ›์„(fetching) ์ˆ˜ ์žˆ๋„๋ก ์„ค์ • ํ•  ์ˆ˜ ๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

git config --global --add remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*"

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ๋ชจ๋“  ์ €์žฅ์†Œ์—์„œ ์งง์€ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

git fetch origin
git checkout pr/42

ํ’€ ๋ฆฌํ€˜์ŠคํŠธ๋ฅผ ๋กœ์ปฌ๋กœ ์ฒดํฌ์•„์›ƒ ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Empty Commits

--allow-empty๋ฅผ ์ถ”๊ฐ€ํ•˜์‹œ๋ฉด ์ฝ”๋“œ์˜ ๋ณ€๊ฒฝ ์—†์ด ์ปค๋ฐ‹์„ ๋„ฃ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ git commit -m "Big-ass commit" --allow-empty

์žˆ์„ ๋ฒ•ํ•œ ์‚ฌ์šฉ๋ฒ•์—๋Š” ์ด๋Ÿฐ ๊ฒƒ๋“ค์ด ์žˆ์Šต๋‹ˆ๋‹ค.

  • ํ•œ ๋ญ‰์น˜์˜ ์ผ์„ ์‹œ์ž‘ํ•˜๊ธฐ ์ „์— ์ฃผ์„์œผ๋กœ ์‚ฌ์šฉ
  • ์ฝ”๋“œ์™€ ๊ด€๋ จ์—†๋Š” ํ”„๋กœ์ ํŠธ ์ˆ˜์ •์„ ํ• ๋•Œ ์ฃผ์„์œผ๋กœ ์‚ฌ์šฉ
  • ์ €์žฅ์†Œ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์‚ฌ๋žŒ๊ณผ์˜ ๋Œ€ํ™”
  • ๋‚˜์ค‘์— ๋ฆฌ๋ฒ ์ด์Šคํ•˜์ง€ ์•Š์„ ์ €์žฅ์†Œ์˜ ์ฒซ ์ปค๋ฐ‹์œผ๋กœ ์‚ฌ์šฉ git commit -m "init repo" --allow-empty.

It ain't even that trolololol...

Styled Git Status

$ git status

git status

์ด๋ ‡๊ฒŒ ๋ฐ”๋€๋‹ˆ๋‹ค.

$ git status -sb

git status -sb

๊นƒ status ์ปค๋งจ๋“œ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Styled Git Log

์ด ๋ช…๋ น์„ ์‹คํ–‰ํ•˜๋ฉด

$ git log --all --graph --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative

์ด๋ ‡๊ฒŒ ๋ณด์ž…๋‹ˆ๋‹ค.

git log --all --graph --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative

Palesz๋‹˜ ๊ณ ๋ง™์Šต๋‹ˆ๋‹ค.

NOTE: ์ด ๋ช…๋ น์„ ์•Œ๋ฆฌ์•„์Šค (๋‹จ์ถ• ๋ช…๋ น)์œผ๋กœ ๋„ฃ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์˜ ์†Œ๊ฐœ๋ฅผ ๋ณด์„ธ์š”.

๊นƒ log ์ปค๋งจ๋“œ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Git Query

๊นƒ ์ฟผ๋ฆฌ๋Š” ๋ชจ๋“  ์ด์ „ ์ปค๋ฐ‹ ๋ฉ”์‹œ์ง€์—์„œ ๊ฒ€์ƒ‰ํ•ด ๊ฐ€์žฅ ์ตœ๊ทผ์˜ ์ฟผ๋ฆฌ์— ๋งž๋Š” ์ปค๋ฐ‹์„ ์ฐพ์•„์ค๋‹ˆ๋‹ค.

$ git show :/query

query์—๋Š” ๊ฒ€์ƒ‰ํ•˜๊ณ  ์‹ถ์€ ๋ง์„ (๋Œ€์†Œ๋ฌธ์ž๋ฅผ ๊ตฌ๋ถ„ํ•ด) ๋„ฃ์œผ์„ธ์š”. ์ฃผ์–ด์ง„ ๊ฒ€์ƒ‰์–ด๊ฐ€ ์žˆ๋Š” ๊ฐ€์žฅ ๋งˆ์ง€๋ง‰ ์ปค๋ฐ‹์„ ํ‘œ์‹œํ•˜๊ณ  ๋ณ€๊ฒฝ๋œ ๋ผ์ธ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

$ git show :/typo

git show :/query

NOTE: ๋‚˜์˜ค๋ ค๋ฉด q๋ฅผ ๋ˆ„๋ฅด์„ธ์š”.

Git Grep

Git Grep์€ ํŒจํ„ด์— ๋งค์น˜ํ•˜๋Š” ์ค„์˜ ๋ชฉ๋ก์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

๋‹ค์Œ ๋ช…๋ น์„ ์‹คํ–‰ํ•ด ๋ณด์„ธ์š”.

$ git grep aliases

aliases ๋ฌธ์ž์—ด์ด ํฌํ•จ๋œ ๋ชจ๋“  ํŒŒ์ผ์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

git grep aliases

๋‚˜์˜ค๋ ค๋ฉด q๋ฅผ ๋ˆ„๋ฅด์„ธ์š”.

์—ฌ๋Ÿฌ ํ”Œ๋ ˆ๊ทธ๋ฅผ ์ด์šฉํ•ด์„œ ์ข€ ๋” ๋ณต์žกํ•œ ๊ฒ€์ƒ‰์„ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด,

  • -e ๋‹ค์Œ ํŒŒ๋ผ๋ฏธํ„ฐ๋Š” ํŒจํ„ด (e.g. regex)
  • --and, --or, --not ์œผ๋กœ ์—ฌ๋Ÿฌ ํŒจํ„ด์„ ์กฐํ•ฉ

์ด๋ ‡๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 $ git grep -e pattern --and -e anotherpattern

๊นƒ grep ์ปค๋งจ๋“œ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Merged Branches

$ git branch --merged

์ด ๋ช…๋ น์–ด๋Š” ํ˜„์žฌ ๋ธŒ๋žœ์น˜์— ๋จธ์ง€๋œ ๋ชจ๋“  ๋ธŒ๋žœ์น˜์˜ ๋ชฉ๋ก์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

๊ฑฐ๊พธ๋กœ

$ git branch --no-merged

์ด ๋ช…๋ น์–ด๋Š” ํ˜„์žฌ ๋ธŒ๋žœ์น˜์— ๋จธ์ง€๋˜์ง€ ์•Š์€ ๋ธŒ๋žœ์น˜์˜ ๋ชฉ๋ก์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

๊นƒ branch ์ปค๋งจ๋“œ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Fixup and Autosquash

์ด์ „(HEAD์˜ ํ•œ๊ฐœ ์ด์ƒ ์ „์˜) ์ปค๋ฐ‹์— ์ž˜๋ชป๋œ ๋ถ€๋ถ„์ด ์žˆ๋‹ค๋ฉด, ์˜ˆ๋ฅผ๋“ค์–ด abcde๋ผ๋ฉด, ๋ฌธ์ œ๋ฅผ ์ˆ˜์ •ํ•˜๊ณ  ๋ฐ‘์˜ ์ปค๋งจ๋“œ๋ฅผ ์ž…๋ ฅํ•ด ๊ณ ์น  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ git commit --fixup=abcde
$ git rebase abcde^ --autosquash -i

๊นƒ commit ์ปค๋งจ๋“œ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”. ๊นƒ rebase ์ปค๋งจ๋“œ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Web Server for Browsing Local Repositories

๊นƒ instaweb ์ปค๋งจ๋“œ์„ ์‚ฌ์šฉํ•˜๋ฉด, ์ฆ‰์„์—์„œ gitweb์•ˆ์—์„œ ์ž‘์—…์ค‘์ธ ์ €์žฅ์†Œ๋ฅผ ๋‘˜๋Ÿฌ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์ปค๋งจ๋“œ๋Š” gitweb๊ณผ ๋กœ์ปฌ ์ €์žฅ์†Œ๋ฅผ ๋ธŒ๋ผ์šฐ์ง• ํ•˜๊ธฐ ์œ„ํ•œ ์›น ์„œ๋ฒ„๋ฅผ ์„ค์ •ํ•˜๋Š” ์Šคํฌ๋ฆฝํŠธ์ž…๋‹ˆ๋‹ค.

$ git instaweb

Opens:

Git instaweb

๊นƒ instaweb ์ปค๋งจ๋“œ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Git Configurations

.gitconfig๋Š” ๋ชจ๋“  ์„ค์ •์ด ๋“ค์–ด์žˆ๋Š” ํŒŒ์ผ์ž…๋‹ˆ๋‹ค.

Aliases

์•Œ๋ฆฌ์•„์Šค๋Š” ์ปค์Šคํ…€ ๊นƒ ๋ช…๋ น์–ด๋ฅผ ๋“ฑ๋กํ•  ์ˆ˜ ์žˆ๋Š” ํ•ผํผ์ž…๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด git a๋กœ git add --all๋ฅผ ์‹คํ–‰ํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์•Œ๋ฆฌ์•„์Šค๋ฅผ ์ถ”๊ฐ€ํ•˜๋ ค๋ฉด ~/.gitconfig๋ฅผ ์ฐพ์•„ ๋‹ค์Œ ํฌ๋ฉง์œผ๋กœ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜

[alias]
	co = checkout
	cm = commit
	p = push
	# Show verbose output about tags, branches or remotes
	tags = tag -l
	branches = branch -a
	remotes = remote -v

์ปค๋งจ๋“œ ๋ผ์ธ์—์„œ ๋‹ค์Œ ๋ช…๋ น์„ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

$ git config --global alias.new_alias git_function

์˜ˆ๋ฅผ๋“ค๋ฉด

$ git config --global alias.cm commit

NOTE: ์—ฌ๋Ÿฌ ํ•จ์ˆ˜๋ฅผ ์•Œ๋ฆฌ์•„์Šคํ•˜๋ ค๋ฉด ๋”ฐ์˜ดํ‘œ๋ฅผ ์ด์šฉํ•˜์„ธ์š”.

$ git config --global alias.ac 'add -A . && commit'

์—ฌ๊ธฐ ๋ช‡ ๊ฐ€์ง€ ๊ถŒ์žฅ ์•Œ๋ฆฌ์•„์Šค๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

Alias Current Command What to Type
git cm git commit git config --global alias.cm commit
git co git checkout git config --global alias.co checkout
git ac git add . -A git commit git config --global alias.ac '!git add -A && git commit'
git st git status -sb git config --global alias.st 'status -sb'
git tags git tag -l git config --global alias.tags 'tag -l'
git branches git branch -a git config --global alias.branches 'branch -a'
git cleanup `git branch --merged grep -v '*'
git remotes git remote -v git config --global alias.remotes 'remote -v'
git lg git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -- git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"

์ผ๋ถ€ ์•Œ๋ฆฌ์•„์Šค๋Š” @mathiasbynens๋‹˜์˜ dotfiles์—์„œ ๊ฐ€์ ธ์™”์Šต๋‹ˆ๋‹ค.(https://github.com/mathiasbynens/dotfiles/blob/master/.gitconfig)

Auto-correct

ํ˜„์žฌ git comit๋ฅผ ์น˜๋ฉด ์ด๋Ÿฐ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ git comit -m "Message"
# git: 'comit' is not a git command. See 'git --help'.

# Did you mean this?
# 	commit

comit์„ ์ณค์„ ๋•Œ commit์„ ๋ถ€๋ฅด๋ ค๋ฉด, ์ž๋™ ๊ต์ •์„ ์ผœ๋‘์„ธ์š”.

$ git config --global help.autocorrect 1

์ด์ œ ์ด๋Ÿฐ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$ git comit -m "Message"
# WARNING: You called a Git command named 'comit', which does not exist.
# Continuing under the assumption that you meant 'commit'
# in 0.1 seconds automatically...

Color

๊นƒ ์ปค๋งจ๋“œ ๋ผ์ธ์— ์ƒ‰์„ ๋„ฃ์œผ๋ ค๋ฉด ์ด๋ ‡๊ฒŒ ํ•˜์„ธ์š”.

$ git config --global color.ui 1

๊นƒ config ์ปค๋งจ๋“œ์— ๋Œ€ํ•ด ๋” ์ฝ์–ด ๋ณด์„ธ์š”.

Git Resources

Title Link
Official Git Site http://git-scm.com/
Official Git Video Tutorials http://git-scm.com/videos
Code School Try Git http://try.github.com/
Introductory Reference & Tutorial for Git http://gitref.org/
Official Git Tutorial http://git-scm.com/docs/gittutorial
Everyday Git http://git-scm.com/docs/everyday
Git Immersion http://gitimmersion.com/
Ry's Git Tutorial http://rypress.com/tutorials/git/index.html
Git for Designers http://hoth.entp.com/output/git_for_designers.html
Git for Computer Scientists http://eagain.net/articles/git-for-computer-scientists/
Git Magic http://www-cs-students.stanford.edu/~blynn/gitmagic/
GitHub Training Kit http://training.github.com/kit
Git Visualization Playground http://onlywei.github.io/explain-git-with-d3/#freeplay

Git Books

Title Link
Pragmatic Version Control Using Git http://www.pragprog.com/titles/tsgit/pragmatic-version-control-using-git
Pro Git http://git-scm.com/book
Git Internals PluralSight https://github.com/pluralsight/git-internals-pdf
Git in the Trenches http://cbx33.github.com/gitt/
Version Control with Git http://www.amazon.com/Version-Control-Git-collaborative-development/dp/1449316387
Pragmatic Guide to Git http://www.pragprog.com/titles/pg_git/pragmatic-guide-to-git
Git: Version Control for Everyone http://www.packtpub.com/git-version-control-for-everyone/book