All Projects โ†’ JaeYeopHan โ†’ Minimal_git_command

JaeYeopHan / Minimal_git_command

Licence: mit
๐ŸŒˆ This is a repository that summarizes the Git commands and tips that you should at least know about development.

Programming Languages

basic
69 projects

Projects that are alternatives of or similar to Minimal git command

Pxltrm
๐Ÿ–Œ๏ธ pxltrm - [WIP] A pixel art editor inside the terminal
Stars: โœญ 459 (+488.46%)
Mutual labels:  commandline
Gitviper
Enhanced git experience using the command line
Stars: โœญ 35 (-55.13%)
Mutual labels:  commandline
Autopair.fish
Auto-complete matching pairs in the Fish command line.
Stars: โœญ 63 (-19.23%)
Mutual labels:  commandline
Ttyplot
a realtime plotting utility for terminal/console with data input from stdin
Stars: โœญ 532 (+582.05%)
Mutual labels:  commandline
Ps Webapi
(Migrated from CodePlex) Let PowerShell Script serve or command-line process as WebAPI. PSWebApi is a simple library for building ASP.NET Web APIs (RESTful Services) by PowerShell Scripts or batch/executable files out of the box.
Stars: โœญ 24 (-69.23%)
Mutual labels:  commandline
Scale
Pharo in the shell
Stars: โœญ 41 (-47.44%)
Mutual labels:  commandline
Cobra
A Commander for modern Go CLI interactions
Stars: โœญ 24,437 (+31229.49%)
Mutual labels:  commandline
Pgen
Command-line passphrase generator
Stars: โœญ 68 (-12.82%)
Mutual labels:  commandline
Socli
Stack overflow command line client. Search and browse stack overflow without leaving the terminal ๐Ÿ’ป
Stars: โœญ 911 (+1067.95%)
Mutual labels:  commandline
Commandline
A pure Swift library for creating command-line interfaces
Stars: โœญ 1,099 (+1308.97%)
Mutual labels:  commandline
Fontpreview
Highly customizable and minimal font previewer written in bash
Stars: โœญ 661 (+747.44%)
Mutual labels:  commandline
Launchy
A helper for launching cross-platform applications in a fire and forget manner.
Stars: โœญ 704 (+802.56%)
Mutual labels:  commandline
Commandline
CommandLine parser
Stars: โœญ 45 (-42.31%)
Mutual labels:  commandline
Tio
tio - A simple TTY terminal I/O application
Stars: โœญ 489 (+526.92%)
Mutual labels:  commandline
Gifline
The fast way to put gif in or emails
Stars: โœญ 63 (-19.23%)
Mutual labels:  commandline
Ls
ls on steroids
Stars: โœญ 458 (+487.18%)
Mutual labels:  commandline
Hdfs
A native go client for HDFS
Stars: โœญ 992 (+1171.79%)
Mutual labels:  commandline
Swiftline
Swiftline is a set of tools to help you create command line applications.
Stars: โœญ 1,156 (+1382.05%)
Mutual labels:  commandline
Slackcat
CLI utility to post files and command output to slack
Stars: โœญ 1,127 (+1344.87%)
Mutual labels:  commandline
Ntutils
Various Command Line Utilities Ported to Windows NT
Stars: โœญ 58 (-25.64%)
Mutual labels:  commandline

Minimal_Git_command

Git ์„ ์‚ฌ์šฉํ•˜๋ฉด์„œ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” ๋ช…๋ น์–ด๋“ค์— ๋Œ€ํ•ด ์ •๋ฆฌํ•œ repository ์ž…๋‹ˆ๋‹ค.

Basic

add

git add [file name]

๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์žˆ๋Š” ๋ชจ๋“  ํŒŒ์ผ add

git add .

commit message ์™€ commit

git commit -m "[commit message]"

๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์žˆ๋Š” ๋ชจ๋“  ํŒŒ์ผ add ์™€ ๋™์‹œ์— commit

git commit -am "[commit message]"

remote repository ๋“ฑ๋กํ•˜๊ธฐ

git remote add [remote github repository address]

ํŠน์ • branch ์ƒ์„ฑํ•˜๋ฉฐ remote ์— push ํ•˜๊ธฐ

git push origin [branch name]

branch ๊ฐ„ ์ด๋™ํ•˜๊ธฐ

git checkout [branch name]

branch ์ƒ์„ฑํ•˜๊ธฐ

git checkout -b [branch name]

branch ์ด๋ฆ„ ๋ฐ”๊พธ๊ธฐ

git branch -M [changed name]

์ด์ „ commit ๊ณผ ๋น„๊ตํ•˜์—ฌ ํŒŒ์ผ ๋ณ€๊ฒฝ ์‚ฌํ•ญ ํ™•์ธํ•˜๊ธฐ

git diff

commit log ๋ณด๊ธฐ

git log

git log graph ๋กœ ์ถœ๋ ฅํ•˜๊ธฐ

git log --graph

Useful command

๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์žˆ๋Š” ํŒŒ์ผ ๋ณ€๊ฒฝ ์‚ฌํ•ญ ์ทจ์†Œํ•˜๊ธฐ

git checkout -- [file name]

commit ํ•œ ๊ฐœ ์ทจ์†Œํ•˜๊ธฐ

git reset HEAD^

or

git revert HEAD

๋ฐ”๋กœ ์ด์ „ commit message ์ˆ˜์ •ํ•˜๊ธฐ

git commit --amend

local git repository ์— remote repository ์„ upstream ์œผ๋กœ ๋“ฑ๋กํ•˜๊ธฐ

git remote add --track master upstream [remote github repository address]

master branch ๋ฅผ uptream ์˜ latest version ์œผ๋กœ update ์‹œํ‚ค๊ธฐ

git pull --ff upstream master

์—ฌ๋Ÿฌ commit ์„ ํ•˜๋‚˜๋กœ ํ•ฉ์น˜๊ธฐ(squash)

git rebase -i HEAD~[commit ๊ฐœ์ˆ˜]

.gitconfig์—์„œ ์„ค์ •ํ•ด๋‘” editor ์ฐฝ์ด ๋‚˜ํƒ€๋‚œ๋‹ค. ๊ธฐ์ค€์ด ๋  ๋งจ ์œ„์˜ ํ•œ commit ๋งŒ pick์œผ๋กœ ๋‘๊ณ  ๋‚˜๋จธ์ง€๋Š” squash๋ผ๋Š” ๋ช…๋ น์–ด๋กœ ๋ฐ”๊ฟ”์ค€๋‹ค. :wq ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ์ €์žฅํ•˜๊ณ  ์ข…๋ฃŒํ•œ๋‹ค. ๊ทธ๋Ÿฌ๋ฉด ๋˜ ๋‹ค๋ฅธ editor ์ฐฝ์ด ๋‚˜ํƒ€๋‚˜๋Š”๋ฐ, commit message ๋ฅผ ์„ค์ •ํ•˜๋Š” editor ์ด๋‹ค. ์›ํ•˜๋Š” commit message ๋ฅผ ์ž…๋ ฅํ•˜๊ณ  :wq ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ์ €์žฅํ•˜๊ณ  ์ข…๋ฃŒํ•ด์ฃผ๋ฉด squash ๊ฐ€ ๋œ๋‹ค.

git history ์ถœ๋ ฅํ•˜๊ธฐ

git reflog

๋ฐ”๋กœ ์ด์ „ commit ์— ์ƒˆ๋กœ์šด ํŒŒ์ผ ๋ณ€๊ฒฝ ์‚ฌํ•ญ์„ ์ถ”๊ฐ€ํ•˜๊ธฐ

git commit -C HEAD --amend

cf> ๋งŒ์•ฝ push ๋ฅผ ํ•œ ์ƒํƒœ๋ผ๋ฉด -f์˜ต์…˜์„ ํ†ตํ•ด์„œ push ๋ฅผ ํ•ด์ค˜์•ผ ํ•œ๋‹ค. commit ์„ ์ƒˆ๋กœ ์ƒ์„ฑํ•˜์ง€ ์•Š๊ณ  ๋ณ€๊ฒฝ์‚ฌํ•ญ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋ณด์ด์ง€๋งŒ ๋‚ด๋ถ€์ ์œผ๋กœ๋Š” ์ƒˆ๋กœ์šด ์ปค๋ฐ‹์ด ์ƒ๊ธฐ๋Š” ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— push ๋œ commit ๊ณผ ๋‹ค๋ฅธ commit ์ด๋‹ค.

ํŒŒ์ผ์˜ ๋ณ€๊ฒฝ ์ด๋ ฅ์„ ๋ฌด์‹œํ•ด์„œ stage ์—์„œ ์ž„์‹œ๋กœ ์ œ์™ธํ•˜๊ธฐ

git update-index --assume-unchanged [ํŒŒ์ผ๋ช…]

ํŒŒ์ผ์˜ ๋ณ€๊ฒฝ ์ด๋ ฅ์„ ๋ฌด์‹œํ•ด์„œ stage ์—์„œ ์ž„์‹œ๋กœ ์ œ์™ธํ•œ ์ƒํ™ฉ์„ ๋˜๋Œ๋ฆฌ๊ธฐ

git update-index --no-assume-unchanged [ํŒŒ์ผ๋ช…]

ํ˜„์žฌ branch ์—์„œ ๋ณ€๊ฒฝ ์‚ฌํ•ญ ์ปค๋ฐ‹์—†์ด ์ €์žฅํ•ด๋‘๊ธฐ

git stash

์ €์žฅํ•ด๋‘์—ˆ๋˜ ๋ณ€๊ฒฝ ๋‚ด์—ญ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ

git stash pop

๋‹ค๋ฅธ branch ์˜ ํŠน์ • commit ๊ฐ€์ ธ์™€์„œ merge ํ•˜๊ธฐ

git cherry-pick [COMMIT_HASH_NUMBER]

upstream ์ œ๊ฑฐํ•˜๊ธฐ

git branch --unset-upstream

์ƒํ™ฉ์— ๋”ฐ๋ฅธ git command ์ง‘ํ•ฉ

์ƒํ™ฉ 1. conflict ๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ์ƒํ™ฉ

์—ฌ๋Ÿฌ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์ด ์žˆ์ง€๋งŒ ๊ทธ ์ค‘ ๋‘ ๊ฐ€์ง€.

git merge upstream/master
(resolve conflict in editor)
git add src
git commit
git rebase upstream/master
(resolve conflict in editor again)
git add src
git rebase --continue
git push -f upstream YOUR_BRANCH_NAME

or

git fetch upstream
git rebase upstream/master
(resolve conflict)
git add .
git rebase --continue
git push -f origin [YOUR_WORKING_BRANCH_NAME]

์ƒํ™ฉ 2. ๊ณผ๊ฑฐ commit ์— fix ํ•œ commit ์ด ์กด์žฌํ•˜์—ฌ ์ด commit ์ˆœ์„œ๋ฅผ ์ •๋ ฌํ•˜๊ณ  ์‹ถ์€ ์ƒํ™ฉ

์–ด๋–ค commit ์ด ์ด๋ฏธ ์˜ฌ๋ผ๊ฐ”๋Š”๋ฐ ๊ทธ commit ์— ํ•ด๋‹นํ•˜๋Š” ์ˆ˜์ • ์‚ฌํ•ญ์ด ๋ฐœ์ƒํ•˜๋ฉด ๊ทธ์— ํ•ด๋‹นํ•˜๋Š” fix commit ์„ ์ถ”๊ฐ€ํ•  ๊ฒฝ์šฐ๊ฐ€ ์žˆ๋‹ค. ์ด ๋•Œ, commit ์˜ ์ˆœ์„œ๊ฐ€ ๋‚œ์žกํ•ด์ง€๋Š”๋ฐ ์ด ๊ฒฝ์šฐ,fixup๊ณผ autosquash command ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

git commit --fixup [HASH]

์ด๋ ‡๊ฒŒ ํ•ด์„œ ํ•ด๋‹น fix commit ์„ ์ถ”๊ฐ€ํ•ด๋†“์€ ๋‹ค์Œ์—

git rebase -i --autosquash [HASH]

์œ„ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด์„œ squash ํ•ด์ฃผ๋ฉด ์ปค๋ฐ‹ ์ˆœ์„œ๋„ ์ •๋ ฌ๋˜๋ฉด์„œ ํ•˜๋‚˜์˜ commit ์œผ๋กœ squash ๋œ๋‹ค. ์œ„ ๋ช…๋ น์–ด์—์„œ HASH๋ž€ ์–ด๋Š ์ปค๋ฐ‹๋ถ€ํ„ฐ squash ๋ฅผ ํ•  ๊ฒƒ์ธ๊ฐ€๋ฅผ ์˜๋ฏธํ•œ๋‹ค.

cf> fixup ๊ณผ squash ๊ทธ๋ฆฌ๊ณ  squeeze ์˜ ์ฐจ์ด์ 
squash๋Š” ์ƒˆ๋กœ์šด ์ธํ„ฐํŽ˜์ด์Šค๊ฐ€ ์—ด๋ฆฌ๋ฉด์„œ commit message ๋„ ์ˆ˜์ •(ํฌํ•จ ๋˜๋Š” ๋ฐฐ์ œ)ํ•  ์ˆ˜ ์žˆ๋‹ค. fixup์€ commit message ๋ฅผ pickํ•œ commit ์— ๋Œ€ํ•ด์„œ๋งŒ ์ ์šฉํ•œ๋‹ค. squeeze๋Š” squash ํ•˜๊ณ ์ž ํ•˜๋Š” ๋ชจ๋“  commit message ๋ฅผ ํฌํ•จํ•˜๋ฉด์„œ squash ํ•œ๋‹ค.


์•Œ์•„๋‘๋ฉด ์“ธ๋ชจ์žˆ๋Š” Git Tip

Git command alias

Git์„ ์„ค์น˜ํ•œ ๋””๋ ‰ํ† ๋ฆฌ์—๋Š” .gitconfig ํŒŒ์ผ์ด ์กด์žฌํ•œ๋‹ค. ์ด ํŒŒ์ผ์—์„œ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” ๋ช…๋ น์–ด์— ๋Œ€ํ•ด์„œ alias ๋ฅผ ์ง€์ •ํ•ด์ค„ ์ˆ˜ ์žˆ๋‹ค.

[alias]
    g = git
    st = status
    co = checkout
    ad = add
    cm = commit -m
    acm = commit -am
    ph = push
    rb = rebase -i
    fh = fetch
    df = diff
    br = branch -a
    lg = log --graph --abbrev-commit --decorate --format=format:'%C(cyan)%h%C(reset) - %C(green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(yellow)%d%    C(reset)' --all
    re = reset HEAD\\^
    fu = fetch upstream
    rum = rebase upstream/master
    pom = push origin master
    list = config --get-regexp alias
    readme = !git add . && git commit -m "Update README.md" && git push origin master
    docs = !git add . && git commit -m "Update" && git push origin master
    update = !git fetch upstream && git rebase upstream/master && git push origin master

Commit Log format

  • ์ œ๋ชฉ๊ณผ ๋ณธ๋ฌธ์„ ๋นˆ ํ–‰์œผ๋กœ ๋ถ„๋ฆฌํ•œ๋‹ค
  • ์ œ๋ชฉ ํ–‰์„ 50 ์ž๋กœ ์ œํ•œํ•œ๋‹ค
  • ์ œ๋ชฉ ํ–‰ ์ฒซ ๊ธ€์ž๋Š” ๋Œ€๋ฌธ์ž๋กœ ์“ด๋‹ค
  • ์ œ๋ชฉ ํ–‰ ๋์— ๋งˆ์นจํ‘œ๋ฅผ ๋„ฃ์ง€ ์•Š๋Š”๋‹ค
  • ์ œ๋ชฉ ํ–‰์— ๋ช…๋ น๋ฌธ์„ ์‚ฌ์šฉํ•œ๋‹ค
  • ๋ณธ๋ฌธ์„ 72 ์ž ๋‹จ์œ„๋กœ ๊ฐœํ–‰ํ•œ๋‹ค
  • ์–ด๋–ป๊ฒŒ ๋ณด๋‹ค๋Š” ๋ฌด์—‡๊ณผ ์™œ๋ฅผ ์„ค๋ช…ํ•œ๋‹ค
  • ์ œ๋ชฉ
    • ๋Œ€๋ฌธ์ž, ๋™์‚ฌ๋กœ ์‹œ์ž‘. ์•ž์— 'If applied, this commit will '๊ฐ€ ์ƒ๋žต๋œ ๊ฒƒ์œผ๋กœ ๊ฐ„์ฃผ
    • ๊ฐ€๊ธ‰์  50 ์ž ์•ˆ์ชฝ
    • ๋งˆ์นจํ‘œ ์ƒ๋žต
  • ๋ณธ๋ฌธ
    • 3 ๋ฒˆ์งธ ์ค„๋ถ€ํ„ฐ ์‹œ์ž‘ (๋‘๋ฒˆ์งธ ์ค„์€ ๋น„์›€)
    • ์ตœ๋Œ€์ค„ ๋„ˆ๋น„๋Š” 80 ์ž. ์ด์ƒ์€ ์ค„๋ฐ”๊ฟˆ

์ถ”์ฒœ ๋™์‚ฌ(personal)

  • Add : ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ ๋˜๋Š” api ์ถ”๊ฐ€
    • ์˜ˆ) Add API creating PDF
  • Remove : ์ œ๊ฑฐ
    • ์˜ˆ) Remove unused local variables
  • Enhance : ๊ธฐ๋Šฅ ๋˜๋Š” ์„ฑ๋Šฅ์˜ ํ–ฅ์ƒ
    • ์˜ˆ) Enhance performance in select queries
  • Fix : ๋ฒ„๊ทธ, ์˜คํƒ€, ์Šคํƒ€์ผ์˜ ์ˆ˜์ •
    • ์˜ˆ) Fix typos in Javadoc
    • ์˜ˆ) Fix styles for standards of Naver Corp
  • Upgrade : ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ฒ„์ „ ์—…๊ทธ๋ ˆ์ด๋“œ
    • ์˜ˆ) Uprade commons-dbcp to 2.3.1
  • Document : ๋ฌธ์„œํ™”
  • Refactor : ๋ฆฌํŒฉํ† ๋ง
  • Update : ๋‹ค๋ฅธ ์ฃผ๋ณ€ ์ƒํ™ฉ์— ๋งž์ถ”์–ด์„œ ๊ฐฑ์‹ 
    • ์˜ˆ) Update README.md for 1.0 release
  • Polish : ์žก๋‹คํ•œ ์ˆ˜์ • ๋ฌถ์Œ (๋‹ค๋ฅธ ์ ์ ˆํ•œ ๋ฌธ๊ตฌ๊ฐ€ ์—†์„ ๊ฒฝ์šฐ ์‚ฌ์šฉ)

Reference>

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].