配置用户信息
git config --list
git config --system --list
git config --global --list
git config --local --list
设置git用户名、密码、邮箱的配置(全局配置)
git config --global user.name "YOUR NAME"
git config --global user.email "YOUR EMAIL ADDRESS"
git config --global user.password 密码
仓库配置
git init
git clone <URL>
查看
git log
git log --graph
git reflog
git remote
git remote -v
git remote add origin <URL>
git fetch [remote-name]
git pull
创建本地分支与远程分支的连接关系
git branch --set-upstream-to <branch-name> origin/<branch-name>
修改和提交
git stash
同时备份本地所做的修改,之后就可以正常git pull了
git status
git diff
git add .
git add
git mv
git rm
git rm --cached
git commit -m “commit message”
git commit --amend
git push origin master
分支和标签
git branch
git branch -r
git branch -a
git branch [branch-name]
git checkout -b [branch-name]
git checkout [branch-name]
git branch -d [branch-name]
git push origin --delete [branch-name]
撤销提交
git reset --hard HEAD~1
git reset --hard HEAD^
git log -g
git reset --hard 7d3e12
git push -f origin dev
重命名远程分支(不进行第一步操作可直接推送新分支到远程仓库)
git push --delete origin test-branch
git branch -m test-branch new-test-branch
git push origin new-test-branch
新建本地仓库,与远程仓库建立联系,并拉取某一分支到本地
git init
git remote add origin <URL>
git remote -v
git pull
git pull origin dev:dev