git config --global user.email "my_email"
git config --global user.name "my_name"
git init
git status
git add .
git add -A
git commit -m “commit message”
# 顯示資訊
git remote -v
git remote show origin
# 刪除目前origin
git remote rm origin
# 新增origin
git remote add origin git@github.com:SongRongLee/xxxxx.git
git push -u origin master
or
git branch -u origin/master
#以後只需要:
git push
git reset --hard HEAD^
git reset --hard HEAD~2
# 以遠端分支為藍本建立本地new-branch
git checkout -b new-branch origin/master
# Delete a remote branch
git push -d origin bad-branch
# Delete a local branch
git branch -d bad-branch
# Sync remote branch information after deletion
git fetch --prune
# List all remote and local branches
git branch -a
# 修改branch名稱
git branch -m my-new-name
# push本地的local-branch到origin/remote-branch
git push origin local-branch:remote-branch
# Shows changes from from_branch to to_branch
git diff from_branch to_branch
# pull但是保留local change
git stash
git pull
git stash pop
# Stash untracked files
git stash -u
# List all stashes
git stash list
# Pop a certain stash
git stash pop stash@{n}
# Stash with a given message
git stash -m my_message
git update-ref -d HEAD
git reset
- Discard changes on one file
git checkout -- filename
- Force overwrite local repo
git reset --hard origin/master
git reset HEAD@{1}
git mv
git status --ignored
- Remove untracked files and directories
git clean -dn # Dry run
git clean -df # Actual remove
- Check SHA-1 of commits from history
git reflog