git常用命令记录
git仓库初始化
git init
查看git仓库状态
git status
初始化git仓库
- 进入本地代码目录
- git init
- git add .
- git commit -m "提交信息"
- git remote add origin 远程仓库地址
fatal: remote origin already exists.
git remote -v 查看远程库信息
git remote rm origin(删除关联的origin的远程库)
git基本工作流程
将文件加入缓存区
> git add .
> git add test_*
将缓存区的文件提交到仓库
> git commit -m "提交信息"
将本地仓库代码 push到 远程仓库
> git push origin branch_name
拉取远程分支到本地
> git pull origin branch_name
分支管理
git branch #显示本地分支
git branch -a #查看所有分支(包括本地和远程)
git branch new_branch_name #新建分支
git checkout new_branch_name #切换分支
git branch -d new_branch_name #删除分支
git checkout -b new_branch_name #新建分支并切换到新建的分支
git branch --set-upstream-to=origin/query_vip #将本地 query_vip 分支关联到远程 query_vip 分支
推送所有标签
git push origin --tags
删除untrack文件
git clean -fd #删除文件和目录 加上【-n】预览将要删除的文件
将文件从暂存区删除
git rm --cached file_name
You have divergent branches and need to specify how to reconcile them.
git config pull.rebase false
git pull
强制覆盖本地代码(与git远程仓库保持一致):
git fetch --all
git reset --hard origin/master
git pull

浙公网安备 33010602011771号