10.gihub
github的双重验证2FA登录方法
github启用2fa后,需要手机在应用市场里搜authenticator,下载那个叫authing令牌的app,打开
然后在github页面
注意,特别要保存下来2FA recovery code,见下图最下方那个recovery codes——view,并且保存的文件名就是这个名字,方便后面检索到。否则一旦更换手机,你就无法获得你的账户了。
- 打开GitHub,从右上角选择【设置】,或者点击https://github.com/settings/security
- 从“个人设置”中选择【password and authentication】,然后往下拉,来到【Two-factor authentication】区域 —— 点击 “Authenticator app” 右侧的 Edit,就会弹出 显示 QR 代码, 请勿关闭此页面。

- 手机打开Authenticator应用,
从右上角的【+】号添加帐户, (Google、Facebook 等) 选择其他帐户,然后扫一扫github页面上的这个QR码
- 扫描完成之后出现6个数字,将这6个数字输入到页面上,帐号就添加到Authenticator中了。

- 随后手机app上不断刷新这6个数字,切到github登录页面,即可将这个动态验证码输入登录页面里了。
注意!要将app里2FA的账户导出并保存,就是导出一个二维码保存,下次换手机要导入这个账户。
记录我自己丢失2FA账户申请的经历。
换手机了,authing这个app的账户丢失了。
于是按照
https://blog.csdn.net/fuxily/article/details/140164639


我的是这个样子
根据上图可知,在没有Recovery code的情况下我们可以通过3个步骤来恢复我们的github*账号
验证github账号绑定的邮箱
可以使用以下三种方式之一验证:常用的主机、github中设置的ssh key、personal access token
github客服将在1-3天内人工审核上述信息,如果审核成功,则会发送邮件通知我们
点击绿色的I understand, get started按钮
点击绿色的Send one-time password按钮,向github账号绑定地邮箱发送验证码
打开电子邮箱,输入邮件中的验证码
方式一、使用经常登录或最后一次登录github的设备验证
点击上图中的Verify with this device 按钮,采用这种方式必须使用自己经常登录或最后一次登录成功的电脑执行这些操作。
等待接收github发送地邮件,大概需要1-3个工作日
过了一天多,邮箱收到了邮件
意思是暂时停止了2FA验证,点击里面的链接,输入账户和密码就能登录,然后显示2FA的二维码账户,手机authing app扫码就行了,然后提示下载2FA recovery code文件,里面有好几组的恢复码,保存好。
给github做贡献
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/3xxx
$ git clone https://github.com/3xxx/mindoc.git
Cloning into 'mindoc'...
remote: Enumerating objects: 11960, done.
remote: Counting objects: 100% (823/823), done.
remote: Compressing objects: 100% (595/595), done.
remote: Total 11960 (delta 284), reused 675 (delta 213), pack-reused 11137
Receiving objects: 100% (11960/11960), 90.08 MiB | 10.69 MiB/s, done.
Resolving deltas: 100% (6172/6172), done.
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/3xxx
$ cd mindoc
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/3xxx/mindoc (master)
$ git remote add upstream https://github.com/mindoc-org/mindoc.git
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/3xxx/mindoc (master)
$ git remote -v
origin https://github.com/3xxx/mindoc.git (fetch)
origin https://github.com/3xxx/mindoc.git (push)
upstream https://github.com/mindoc-org/mindoc.git (fetch)
upstream https://github.com/mindoc-org/mindoc.git (push)
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/3xxx/mindoc (master)
$ git fetch upstream master
From https://github.com/mindoc-org/mindoc
* branch master -> FETCH_HEAD
* [new branch] master -> upstream/master
这里先更新一下
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/3xxx/mindoc (master)
$ git pull upstream master
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 1 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), 859 bytes | 859.00 KiB/s, done.
From https://github.com/mindoc-org/mindoc
* branch master -> FETCH_HEAD
397dced..db620be master -> upstream/master
hint: Waiting for your editor to close the file...
/usr/bin/bash: line 1: q: command not found
shell returned 127
Press ENTER or type command to continue
Merge made by the 'ort' strategy.
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/3xxx/mindoc (master)
$ git add .
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/3xxx/mindoc (master)
$ git commit -m "update images upload"
[master af88388] update images upload
2 files changed, 306 insertions(+), 260 deletions(-)
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/3xxx/mindoc (master)
$ git push
warning: ----------------- SECURITY WARNING ----------------
warning: | TLS certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: HTTPS connections may not be secure. See https://aka.ms/gcm/tlsverify for more information.
warning: ----------------- SECURITY WARNING ----------------
warning: | TLS certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: HTTPS connections may not be secure. See https://aka.ms/gcm/tlsverify for more information.
Enumerating objects: 17, done.
Counting objects: 100% (17/17), done.
Delta compression using up to 20 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (9/9), 3.21 KiB | 3.21 MiB/s, done.
Total 9 (delta 7), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (7/7), completed with 7 local objects.
To https://github.com/3xxx/mindoc.git
397dced..af88388 master -> master1 win下编译mindoc
修改conf里
注释掉mysql
取消sqlite注释
拷贝一个sqlite数据库到database文件夹里,更名为mindoc.db
cmd进入mindoc文件夹
因为用sqlite需要cgo,go env -w CGO_ENABLED=1
https://blog.csdn.net/qq_43625649/article/details/134488353
D:\gowork>cd src\github.com\mindoc
D:\gowork\src\github.com\mindoc>bee run
2 Fork 这个项目
3 Clone 已经 fork 的项目
当你 fork 一个项目之后,你需要把它克隆到你的电脑上,这样你才能开始工作。
要 clone 这个项目,你先打开你自己的 GitHub 主页,找到 fork 过来的项目,打开后点击右上角的 “Clone or download” 按钮,得到复制的地址。
GitHub 为克隆项目提供了两种传输协议: HTTPS 和 SSH 。关于这个主题的更多内容可以看这里。这里假设你决定使用 HTTPS 。
当你复制了项目 URL,你可以在 Git 客户端或者 shell 里 clone 项目:
$ git clone https://github.com/mindoc-org/mindoc.git
Clone 一个项目会在你的硬盘上创建一个文件夹,里面有项目的所有文件,还有跟踪文件变化的 git 文件夹。
注意:
- clone到本地的项目文件夹作为将来提交的文件夹,因此要保持干净,不要在这里面进行开发调试。
本地开发调试要另外再clone这个项目,完成开发后把个别修改的文件拷贝到前面clone的文件夹里,然后在它里面进行git push等提交代码操作。 - 提交到自己fork的项目里后,再进行pull request操作。
4 设置克隆过来的项目
进入克隆过来的项目文件夹,将原来项目的 URL 添加到你的本地代码仓库,这样你就可以随时从原来的项目 pull 最新的修改:
$ git remote add upstream url
我用 upstream (上游) 作为远程仓库的名字,这是 GitHub 的风格,但是你可以用任何名字。
现在远程仓库列表是这样的:
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/mindoc (master)
$ git remote add upstream https://github.com/mindoc-org/mindoc.git
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/mindoc (master)
$ git remote -v
origin https://github.com/engineercms/mindoc.git (fetch)
origin https://github.com/engineercms/mindoc.git (push)
upstream https://github.com/mindoc-org/mindoc.git (fetch)
upstream https://github.com/mindoc-org/mindoc.git (push)这里创建了一个叫做upstream的与源代码origin关联,关联之后,就可以同步源代码库的其他分支到自己的仓库了
在你把自己的修改 push 到你的 fork 之前,从上游拉回一次新的变动。
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/mindoc (master)
$ git fetch upstream master
From https://github.com/mindoc-org/mindoc
* branch master -> FETCH_HEAD
* [new branch] master -> upstream/master
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/mindoc (master)
$ git pull upstream master
From https://github.com/mindoc-org/mindoc
* branch master -> FETCH_HEAD
Already up to date.5 推送
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/mindoc (master)
$ git add .
warning: in the working copy of 'conf/app.conf.example', LF will be replaced by CRLF the next time Git touches it
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/mindoc (master)
$ git commit -m "add prev&next in default read.tpl"
[master 2988fab] add prev&next in default read.tpl
11 files changed, 1776 insertions(+), 95 deletions(-)
create mode 100644 conf/app.conf.example
delete mode 100644 uploads/202404/cover_17c7b2c6745688e0.png
create mode 100644 uploads/202404/cover_17c8260e47e06f18_small.png
create mode 100644 uploads/202404/cover_17c8286be57a8600_small.png
create mode 100644 uploads/202404/cover_17c829abdef5fdc8.png
create mode 100644 uploads/books/2/book.zip
create mode 100644 views/document/test.tpl
delete mode 100644 "win\344\270\213\347\274\226\350\257\221.md"
Administrator@DESK-XDIGIWSFLS MINGW64 /d/gowork/src/github.com/mindoc (master)
$ git push
warning: ----------------- SECURITY WARNING ----------------
warning: | TLS certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: HTTPS connections may not be secure. See https://aka.ms/gcm/tlsverify for more information.
warning: ----------------- SECURITY WARNING ----------------
warning: | TLS certificate verification has been disabled! |
warning: ---------------------------------------------------
warning: HTTPS connections may not be secure. See https://aka.ms/gcm/tlsverify for more information.
Enumerating objects: 33, done.
Counting objects: 100% (33/33), done.
Delta compression using up to 20 threads
Compressing objects: 100% (19/19), done.
Writing objects: 100% (21/21), 249.03 KiB | 27.67 MiB/s, done.
Total 21 (delta 11), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (11/11), completed with 11 local objects.
To https://github.com/engineercms/mindoc.git
6054b5f..2988fab master -> master1. 问题一
甲乙两个程序员正在合作开发一款程序,甲晚上10点push了自己编辑的test.txt文档到GitHub。
乙11点也想要push自己编辑过后的test.txt文档到GitHub,因为乙本地仓库不是最新,乙push时会报错,乙如果使用git pull拉取最新版本,那自己修改的东西丢失了怎么办?
解决办法:
先把自己修改好的代码存放在缓存里,等最新代码拉取下来以后再恢复缓存里的自己修改的代码,乙再push。
前提是两人不要修改相同的地方,可能会产生冲突!
步骤如下:
git stash save "这里是注释"
git pull
git stash pop
git stash list
git stash show2. 问题二
乙在上个问题背景时不知道甲做了提交,直接commit了自己的test.txt文件,想取消自己的commit怎么办?
解决办法:
git reset --soft HEAD^原文链接:https://blog.csdn.net/m0_61502213/article/details/120620168
git-拉取代码不覆盖本地修改的代码
1 先将本地代码放在暂存区:
git stash
2 将远程gitlab上代码拉取下来:
git pull
3 将1中暂存区的代码放回本地:
git stash pop
4 接下来将代码合并到master:
4.1 提交到远程库:
方法一:提交tracked的修改
git commit -am 'comment code1'
git push方法二:提交未tracked的修改
git add -u
git commit -m 'comment code1'
git push4.2 codereview:
arc diff origin/master4.3 合并到master:
arc land --onto master其他:
git add -u <==> git add –update提交所有被删除和修改的文件到数据暂存区
git add .提交所有修改的和新建的数据暂存区
git add -A <==>git add –all提交所有被删除、被替换、被修改和新增的文件到数据暂存区
【gitHub】在提PR(pull request)时提交指定的commit
一、背景
今天在提PR的时候,发现以前一些旧的commit也一起被提交上去了,这样比较不友好,在网上研究了一些方法,在这里总结记录一下。
二、方法
对于方法博主研究后有两种,一种是通过版本非强制回退,然后再重新commit一次,这样就能够合并之前的所有commit。另外一种是通过使用cherry-pick选择commit进行提交。博主推荐使用第二种。
2.2.使用cherry-pick进行提交
cherry-pick是在新分支下选择本地分支的commit记录进行合并的操作,因此只需要在本地新建一个上游仓库(注意不是远程仓库)的本地分支,再合并想要提交的commit即可。
首先,配置上游仓库地址并同步。
git remove add upstream XXX.git // XXX.git是上游仓库地址git fetch
在github上或者在本地运行git log选取commit记录。
注意:需要选择上次PR之后的除了merge操作的所有commit的id。
在本地从上游仓库中拉取新的分支。
注意:upstream是上游仓库,在第一步配置过;origin是自己的远程仓库;main是主分支名。
git checkout -b new_branch upstream/main
在new_branch的分支上cherry-pick所有commit记录。
注意:要选择所有未提交PR的所有commit,这样才不会出错。
git cherry-pick commit_id1 commit_id2 commit_id3 ......
将新分支推送到远程仓库。
git push origin new_branch
在github提PR的时候选择新推送的分支即可。
PR被接受后,可选择删除新建立的本地分支和远程分支。
git branch -D new_branch // 在main分支删除new_branch分支git push origin --delete new_branch // 删除远程仓库分支
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/wuchus/article/details/126018674
最后编辑:秦晓川 更新时间:2026-03-17 23:28