- git init
To create a new Git repository
git init
git init <directory>
git init <directory>
- git clone
Clone the repository in local machine
git clone <repo>
git clone <repo> <directory>
- git config
Define author name, email for commits
git config user.name <name>
git config --global user.name <name>
git config --global user.email <email>
Example:
git config user.name kien.nguyen
git config --global user.name kien.nguyen
git config --global user.email nguyenanhkien2a@gmail.com
- git diff
View a change in details (line by line)
git diff <file>
git diff --cache
git diff --base <file>
git diff <source_branch> <target_branch>
- git status
List files in staged, unstaged, untracked.
git status
- git reset
Clear all local changes
git reset
git reset <file>
git reset --hard
git reset <commit>
git reset --hard <commit>
- git add
Add a change to staging area, staging area will be used into commit
git add <file>
git add <directory>
git add .
git add *
- git commit
Commit your changes in staging area to HEAD in local working repository
git commit -m "your message"
Commit all your changes in staging/unstaging to HEAD in local working reposiroty
git commit -a -m "your message"
Edit the last commit
git commit --amend
- git log
View committed snapshots
git log
git log -n <number>
git log --oneline
git log --stat
git log <file>
git log -p
git log --author="<pattern>"
git log --grep="<pattern>"
- git fetch
Fetch latest changes from remote repository
git fetch
git fetch origin
- git pull
Fetch and update commits from remote repository into local working repository
git pull
- git push
Push local working branch to remote repository
git push
git push origin <remote_branch>
Example:
git push origin master
- git branch
List all branches in your local repository
git branch
- git checkout
Checkout a branch to working tree
git checkout <branch>
No comments:
Post a Comment