Tools
Useful Git Commands Cheatsheet

Initializes
Initializes a new Git repository
git init
Add files
ในการเพิ่มไฟล์เข้าไปในสถานะ staging area เราจะใช้คำสั่ง
git add <files>
แล้วตามด้วยชื่อไฟล์ที่ต้องการเพิ่ม แต่ถ้าเราต้องการเพิ่มทุกไฟล์ทุกโฟลเดอร์ สามารถใช้คำสั่ง
git add .
เพื่อเพิ่มทุกไฟล์ทุกโฟลเดอร์เข้าไปใน staging area ได้
Reset
Undo the changes to the local files, and restore to the last commit.
git reset
Show Log
Used to view the entire commit history.

git log
Commit
Used to commit files (locally) on the repository.

git commit -m "message"
Clone
Used to download existing code from a remote repository.

git clone <url>
Work with Branch
Used to list all the local branches on the machine.
git branch
Create new Branch
Used to create a new branch locally.
git branch <branch-name>
Delete Branch
Used to delete a branch.
git branch -d <branch-name>
Rename Branch
Used to rename the current working branch.
git branch -m <new-name>
Merge Branch
Merges the provided branch with the current working branch.
git merge <branch-name>
Switch Current Branch
Used to switch from the current branch to another one.
git checkout <branch-name>
Switch and Create new Branch
Creates a new branch and switches to the new one.
git checkout -b <branch-name>
Push
Used to save all commits to the remote repository.
git push <remote> <branch-name>
Pull
Used to pull down all the updates from the remote repository.
git pull <remote>
Remove
Used to remove a file from the working directory.

git rm <file-name>
Stash
Used to temporarily remove uncommitted changes.
git stash
See Difference
Displays the difference between files in two commits or between a commit and your current repository.
git diff
คลิกเพื่อแสดงความคิดเห็น