๐Ÿš€ย ย ย 70์„ธ ์ด์ „์— ํ•œ ๋ชจ๋“  ์ผ์€ ์‹ ๊ฒฝ ์“ธ ๊ฐ€์น˜๊ฐ€ ์—†๋‹ค. - ํ˜ธ์ฟ ์‚ฌ์ด

Git Command Cheatsheet

2024.08.22
2๋ถ„

Create a New Repository

$ git init
$ git add --all
$ git commit -m "First draft"
$ git remote add origin https://github.com/<user>/<repo>.git
$ git push -u origin master

Working with local changes

$ git status
$ git add --all
$ git add -p <file>
$ git commit -m "Commit message here"

View History

$ git log
$ git log -p <file>
$ git blame <file>

Branching and Merging

$ git branch -av
$ git branch <new-branch>
$ git checkout <branch>
$ git merge <branch>
$ git branch -d <branch>
$ git branch -D <branch>

Undoing Changes

$ git reset --hard HEAD
$ git checkout HEAD <file>
$ git revert <commitId>

Recover on Origin changes

$ git reset --hard HEAD^
$ git reset --hard <commitId>
$ git push --force

Clone Repository

$ git clone https://github.com/<user>/<repo>.git

Pull Repository

$ git pull origin <branch>

Push Repository

$ git push origin <branch>

Stash

# Stash changes
$ git stash

# List all stashes
$ git stash list

# Apply the latest stash
$ git stash apply

# Drop the latest stash
$ git stash drop

Tagging

# Create a new tag
$ git tag <tag-name>

# List all tags
$ git tag

# Delete a tag
$ git tag -d <tag-name>

# Push tag to remote
$ git push origin <tag-name>

View Differences

# Show changes between working directory and index
$ git diff

# Show changes between working directory and last commit
$ git diff HEAD

Working with Remotes

# List all remote repositories
$ git remote -v

# Add a new remote repository
$ git remote add <name> <url>

# Remove a remote repository
$ git remote remove <name>

ํ”„๋กœํ•„ ์‚ฌ์ง„
Nanutbae
A small boat sailing freely on the sea of curiosity โŠน เฃช ๏น๐“Š๏น๐“‚๏นโŠน เฃช ห–