[git]git常用命令

查看用户名 git config user.name
查看邮箱 git config user.email
初始化仓库 git init
添加到暂存区 git add .
从暂存区删除 git rm --cached xxx
提交到本地仓库 git commit -m '说明'
提交到远程仓库 git push
查看历史记录 git reflog
详细历史记录 git log
回滚历史版本 git reset --hard 版本号
创建分支(复制当前所在分支)git branch 分支名
查看分支 git branch
切换分支 git checkout 分支名
删除分支(需要切换到其他分支) git branch -d 分支名
强制删除分支(如果分支没有合并,-d无法删除) git branch -D 分支名
合并(把源分支合并到当前分支) git merge 源分支
============================================================
本地连接远程仓库 git remote add origin 远程仓库地址
将本地仓库push到远程仓库 git pull origin master --allow-unrelated-histories
git push -u origin master
将本地仓库覆盖远程仓库 git push -f origin master
无本地仓库 从远程拉取(https方式) git clone 仓库地址
连接到远程仓库之后 拉取代码 git pull
推送新分支/代码 git push
指定远程分支复制新分支并切换 git checkout -b xxx origin/xxx

posted @ 2022-07-13 17:57  诚可君  阅读(7)  评论(0编辑  收藏  举报