LovingPython

Git基础操作大全

2019-06-01  本文已影响0人  月蚀様
git init

git init folder

git config --global user.name "your name"
git config --global user.email "your_email@youremail.com"

git remote add origin git@github.com:yourName/yourRepo.git

git clone /path/to/repository [directory]
git clone username@host:/path/to/repository [directory]

# Operation of git add
git add *
git add re_sentence
git add file1 file2

git commit -m "message"

git commit -am "message"

git status -s

git diff  # 尚未缓存的改动
git diff --cached  # 查看已缓存的改动
git diff HEAD  # 查看已缓存的与未缓存的所有改动
git diff --stat # 显示摘要而非整个diff

git reset HEAD  # 取消已缓存的内容/取消之前git add添加,但不希望包含在包含在下一提交快照中的缓存(?)

git rm file_name
git rm -f file_name
git rm --cached file_name

git mv .. ..  # 用于移动or重命名一个文件、目录、软链接

git branch branch_name

git checkout branch_name

git merge

git checkout -b new_branch

git branch -d branch_name

# useful tips
gitk
git config color.ui true
git config format.pretty online
git add -i

git log --oneline --graph

git log --reverse

git log --author

git log --no-merges

gut log --oneline --before={1.week.ago} --after={2019-05-25}

git tag -a v1.0
上一篇下一篇

猜你喜欢

热点阅读