Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaeyeophan/minimal_git_command
π This is a repository that summarizes the Git commands and tips that you should at least know about development.
https://github.com/jaeyeophan/minimal_git_command
basic commandline git
Last synced: 20 days ago
JSON representation
π This is a repository that summarizes the Git commands and tips that you should at least know about development.
- Host: GitHub
- URL: https://github.com/jaeyeophan/minimal_git_command
- Owner: JaeYeopHan
- License: mit
- Created: 2017-06-23T10:38:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-30T07:15:10.000Z (about 6 years ago)
- Last Synced: 2024-05-02T05:05:34.776Z (8 months ago)
- Topics: basic, commandline, git
- Homepage:
- Size: 7.81 KB
- Stars: 103
- Watchers: 3
- Forks: 39
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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 λ₯Ό μ§μ ν΄μ€ μ μλ€.
```.gitconfig
[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>
- [How to Write a Git Commit Message](https://item4.github.io/2016-11-01/How-to-Write-a-Git-Commit-Message)