了解如何连接你的 GitHub 仓库,并直接在手机上的 Pocket Code 中管理代码。
过去在手机上管理仓库一直很麻烦。有了 Pocket Code,它就像在桌面端一样简单。
完成!现在你可以访问所有仓库了。
有三种克隆方式:
方式 A:从应用中
1. 在主屏幕上点击 "+" 按钮
2. 选择 "克隆仓库"
3. 搜索或粘贴 URL
4. 选择本地位置
方式 B:从浏览器
1. 在 GitHub Mobile 中打开仓库
2. 点击 "分享"
3. 选择 "使用 Pocket Code 打开"
方式 C:使用 Git 命令
git clone https://github.com/username/repo.git
# 查看状态
git status
# 添加更改
git add .
# 提交
git commit -m "Fix: correct login bug"
# 推送
git push origin main
或者使用可视化界面:
# 查看分支
git branch
# 创建分支
git checkout -b feature/new-functionality
# 切换分支
git checkout main
# 合并
git merge feature/new-functionality
当出现冲突时:
# 手动解决后
git add conflict-file.js
git commit -m "Resolve conflict in conflict-file.js"
临时保存更改:
# 保存更改
git stash
# 查看暂存列表
git stash list
# 恢复更改
git stash pop
# 1. 确保你在 main 分支上
git checkout main
# 2. 拉取最新更改
git pull
# 3. 进行修复
# ... 编辑文件 ...
# 4. 提交并推送
git add .
git commit -m "Fix: urgent production bug"
git push
# 1. 从 main 创建分支
git checkout main
git pull
git checkout -b feature/new-api
# 2. 开发
# ... 实现该功能 ...
# 3. 频繁提交
git add .
git commit -m "feat: add /api/users endpoint"
# 4. 推送并创建 PR
git push -u origin feature/new-api
# 然后在应用中创建 PR
# 1. 从 production 创建分支
git checkout production
git checkout -b hotfix/critical-bug
# 2. 快速修复
# ... 修复 ...
# 3. 提交并直接合并
git add .
git commit -m "hotfix: fix critical error"
git checkout production
git merge hotfix/critical-bug
git push
✅ 好的提交信息:
feat: add Google login
fix: correct email validation
docs: update README with instructions
refactor: simplify search function
❌ 不好的提交信息:
changes
fix
wip
asdfgh
使用具有描述性的名称:
feature/feature-namefix/bug-descriptionhotfix/critical-issuerefactor/refactor-name为了避免每次都进行身份验证:
[email protected]:user/repo.git创建 .gitignore 来忽略文件:
# Dependencies
node_modules/
venv/
__pycache__/
# Build outputs
dist/
build/
*.pyc
# Environment
.env
.env.local
# IDE
.vscode/
.idea/
# OS
.DS_Store
Thumbs.db
自动化任务:
# .git/hooks/pre-commit
#!/bin/sh
npm run lint
npm test
# 先拉取
git pull origin main
# 如果有冲突则解决冲突
# 然后推送
git push
请检查:
# 确认你已推送
git status
# 如果显示 "Your branch is ahead"
git push
有了 Pocket Code,你在手机上就拥有了 Git 和 GitHub 的全部能力。再也没有借口不去完成那个紧急的提交了。
下一篇教程:使用 Vercel 从 GitHub 自动部署
有疑问?加入我们的 Discord
祝编码愉快!🚀