📖 《把 AI 当助手——经济实证研究的诚信、方法与工具》双语网页版:每章中文部在前,English Edition 在后,内容与最新合订 PDF 一致。
附录 G · CNB 代码托管平台操作指南
G.1 注册与登录
浏览器打开
https://cnb.cool,点击「注册」→ 微信扫码登录登录后,点击右上角头像 →「个人设置」→ 左侧菜单「访问令牌」
令牌名填写:
my-research;授权范围勾选「Git 客户端凭据」点击「创建」→ 立即复制 Token(仅显示一次!粘贴到备忘录保存)
[注意] Token 仅显示一次,关闭页面后无法再次查看。如果忘记保存,只能删除旧令牌重新创建。
G.2 创建仓库
点击页面左上角「+」按钮 → 选择「创建仓库」
「仓库归属」选你的个人用户名
「仓库名称」填写项目名(如
my-first-research)「公开性」选「公开」(教师可查看)
点击「创建」
G.3 推送项目到 CNB
在项目目录的终端中执行:
# 初始化 Git 仓库
git init
git add .
git commit -m "Initial commit"
# 关联远程仓库(替换 <用户名> 和 <仓库名>)
git remote add origin https://cnb.cool/<用户名>/<仓库名>.git
# 首次推送
git push -u origin main如果 cnb login 已成功(提示词第 10 步),push 时无需输入密码。
如果 git push 提示认证失败,改用 Token URL:
git remote set-url origin https://cnb:<你的Token>@cnb.cool/<用户名>/<仓库名>.git
git push -u origin mainG.4 CNB 与 Git 命令速查
CNB 的基础 Git 命令与 GitHub 完全相同(都基于 Git):
表 G.1 CNB 与 Git 命令速查。
L3|L3|L3
操作 & Git 命令 & 说明
克隆仓库 & git clone <url> & 从云端下载项目
添加文件 & git add . & 暂存所有修改
提交 & git commit -m "描述" & 保存一个版本快照
推送 & git push origin main & 上传到 CNB 云端
拉取 & git pull origin main & 从云端同步最新版本
查看状态 & git status & 看哪些文件被修改\
G.5 常见问题
表 G.2 常见问题。
L3|L3|L3
报错 & 原因 & 解决cnb login 超时 & 网络问题 & 跳过,改用 Token URL 方式推送git push 要密码 & cnb login 未生效 & 改用 Token URL 或检查凭证助手配置
Authentication failed & Token 复制不全或过期 & 重新创建令牌
403 Forbidden & 推到了教师仓库 & 确认 remote 是自己的仓库地址
updates were rejected & 远程仓库非空 & 在 CNB 网页删除仓库重建空仓库\
G.6 CNB 专属 CLI 命令
除了标准 Git 命令,CNB CLI 还提供平台管理功能:
# 登录/登出/状态
cnb login
cnb logout
cnb status
# 组织管理
cnb organizations list-top-groups
# 仓库管理
cnb repositories list-repos
# Issue 和 PR 管理
cnb issues list-issues --repo <组织>/<仓库>
cnb pulls list-pulls --repo <组织>/<仓库>English Edition
Appendix G · Operating Guide to the CNB Code-Hosting Platform
G.1 Registration and login
Open
https://cnb.coolin a browser, click “Register” → log in by scanning the WeChat QR codeAfter logging in, click your avatar in the top-right corner → “Personal Settings” → “Access Tokens” in the left-hand menu
Name the token
my-research; tick “Git client credentials” in the scope listClick “Create” → copy the token immediately (it is shown only once! paste it into a note)
[Caution] The token is displayed only once and cannot be viewed again after you close the page. If you forget to save it, you must delete the old token and create a new one.
G.2 Creating a repository
Click the “+” button in the top-left corner → choose “Create repository”
Set “Repository owner” to your personal username
Set “Repository name” to the project name (e.g.
my-first-research)Set “Visibility” to “Public” (so the teacher can view it)
Click “Create”
G.3 Pushing a project to CNB
In a terminal inside the project directory, run:
# Initialise the Git repository
git init
git add .
git commit -m "Initial commit"
# Link the remote repository (replace <username> and <repo>)
git remote add origin https://cnb.cool/<username>/<repo>.git
# First push
git push -u origin mainIf cnb login has already succeeded (step 10 of the prompt), pushing needs no password.
If git push reports an authentication failure, switch to a token URL:
git remote set-url origin https://cnb:<yourToken>@cnb.cool/<username>/<repo>.git
git push -u origin mainG.4 Quick reference: CNB and Git commands
CNB’s basic Git commands are exactly the same as GitHub’s (both are built on Git):
Table G.1 Quick reference: CNB and Git commands.
L3|L3|L3
Operation & Git command & Description
Clone a repository & git clone <url> & Download the project from the cloud
Add files & git add . & Stage all modifications
Commit & git commit -m "message" & Save a version snapshot
Push & git push origin main & Upload to the CNB cloud
Pull & git pull origin main & Synchronise the latest version from the cloud
Check status & git status & See which files have changed\
G.5 Frequently asked questions
Table G.2 Frequently asked questions.
L3|L3|L3
Error & Cause & Fixcnb login times out & Network problem & Skip it and push with a token URLgit push asks for a password & cnb login did not take effect & Use a token URL or check the credential-helper configuration
Authentication failed & Token copied incompletely or expired & Recreate the token
403 Forbidden & Pushing to the teacher’s repository & Confirm the remote points to your own repository
updates were rejected & The remote repository is not empty & Delete the repository on the CNB website and recreate an empty one\
G.6 CNB-specific CLI commands
Beyond the standard Git commands, the CNB CLI also provides platform-management functions:
# login / logout / status
cnb login
cnb logout
cnb status
# organisation management
cnb organizations list-top-groups
# repository management
cnb repositories list-repos
# issue and PR management
cnb issues list-issues --repo <org>/<repo>
cnb pulls list-pulls --repo <org>/<repo>Code walkthrough (English note) — cnb login / cnb logout / cnb status manage the session; cnb organizations list-top-groups lists organisations; cnb repositories list-repos lists repositories; and the issues and pulls subcommands list issues and pull requests for a given <org>/<repo>.