Git
程序员技术之旅
个人博客地址:https://www.zhangbj.com
GitHub地址:https://github.com/fendoudebb
展开
-
Git 提示error failed to push some refs to git@github.com
error: failed to push some refs to 'git@github.com:…" Updates were rejected because the remote contains work that you do not have locally.本地和远程的文件应该合并后才能上传本地的新文件git pull origin mastergit push -u origin master原文地址https://www.zhangbj.com/p/31.html.原创 2020-08-02 09:56:37 · 211 阅读 · 0 评论 -
Git 提示You asked me to pull without telling me which branch you...
错误信息Git未关联本地分支与远程分支,报错如下:You asked me to pull without telling me which branch youwant to merge with, and 'branch.master.merge' inyour configuration file does not tell me, either. Pleasespecify which branch you want to use on the command line andtry a原创 2020-08-02 09:55:31 · 1078 阅读 · 0 评论 -
Git 提示refusing to merge unrelated histories
错误提示git push时提示:fatal: refusing to merge unrelated histories解决方法git pull --allow-unrelated-histories原文地址https://www.zhangbj.com/p/29.html原创 2020-08-02 09:53:23 · 131 阅读 · 0 评论 -
Git命令之查看及设置用户名邮箱
GitHub统计contributions是以邮箱依据的查看用户名和邮箱地址git config user.namegit config user.email修改用户名和邮箱地址git config --global user.name "username"git config --global user.email "email"原文地址https://www.zhangbj.com/p/27.html...原创 2020-08-02 09:50:17 · 2626 阅读 · 0 评论 -
Git命令之代码合并rebase
合并代码之rebase合并某个分支上的一系列commits如需要合并commit abc-def-ghi-jkl 到master分支。创建一个新的分支,并指明新分支的最后一个commit:git checkout -b newbranch jkl rebase这个新分支的commit到master(–onto master)。jkl 指明想从哪个特定的commit开始。得到的结果就是commit abc~jkl 都被合并到了master分支。git rebase --ont原创 2020-08-01 12:09:56 · 564 阅读 · 0 评论 -
Git命令之回退到指定commit
1. 查看提交日志git log# 已经删除的commitId可以用git reflog查看git reflog2. 本地代码回到指定的commitid hard模式git reset --hard commitid3. git服务器代码回到指定的commitidgit push -f origin 分支名称...原创 2020-07-31 08:35:55 · 2640 阅读 · 0 评论 -
Git命令之暂存区
不想把dev分支的改动带到master分支可以用此命令暂存当前修改git stash恢复(弹出)暂存区内容会删除stash list所有的内容git stash pop查看暂存区内容列表git stash list恢复(弹出)指定编号的暂存内容会删除stash list中的stashID对应的内容git stash pop stash@{0}恢复(应用)指定编号的暂存内容不会删除stash list中的stashID对应的内容git stash apply stash@.原创 2020-07-31 08:34:15 · 502 阅读 · 0 评论 -
Git命令之本地仓库上传至远程仓库
本地已建立项目,git上已存在地址,初始化项目并上传到git。初始化本地仓库git init添加文件缓存区,符号.代表添加文件夹下所有文件git add .把添加的文件提交到本地仓库,并填写提交备注git commit -m "first commit"把本地库与远程库关联git remote add origin 远程库地址推送至远程仓库# 第一次推送时使用该命令# -u 参数是指定origin为默认主分支git push -u origin mas.原创 2020-07-31 08:33:44 · 216 阅读 · 0 评论 -
Git命令之基础命令
查看状态git status查看分支git branch 创建dev_branch分支(分支名称可任意)git branch 分支名称git branch dev_branch 切换到dev_branch上git checkout dev_branch 创建并切换到dev_branch分支上git checkout -b dev_branch合并分支到master上1.先切换到master git checkout master2.合并分支到master上原创 2020-07-31 08:32:57 · 64 阅读 · 0 评论