初始化
# 初始化
git init
# 克隆
git clone [url]
仓库
# 添加远程仓库
git remote add [name] [url]
# 显示所有远程仓库
git remote -v
# 显示某个远程仓库的信息
git remote show [name]
# 根据仓库名删除仓库
git remote remove <name>
分支
# 列出所有本地分支
git branch
# 列出所有远程分支
git branch -r
# 列出所有本地分支和远程分支
git branch -a
# 新建一个分支
git branch [name]
# 新建一个分支,并切换到该分支
git checkout -b [name]
# 删除一个分支
git branch -d [branch]
添加文件到暂存区
# 添加所有文件
git add .
# 添加指定文件
git add [file]
# 添加指定文件夹
git add [dir]
提交更改
# 提交所有文件
git commit -m "update"
# 修改上一次的提交信息
git commit --amend -m "update"
拉取
# 拉取远程仓库的所有变动
git fetch [remote]
# 变基
git rebase
# 拉取远程仓库的变化,并与本地分支合并
git pull [remote] [branch]
推送
# 推送到指定仓库和指定分支
git push [remote] [branch]
# 推送所有分支到远程仓库
git push [remote] --all
# 强制推送当前分支到远程仓库,即使有冲突
git push [remote] --force
网友评论