Github实用CheatSheet
Git Cheat Sheet
初始化仓库或克隆现有仓库
初始化新的Git仓库
git init克隆现有的仓库
git clone https://github.com/username/repository.git
配置Git
- 配置用户信息(首次使用Git时)
git config –global user.name “Your Name”
git config –global user.email “youremail@example.com“
基本Git操作
查看状态
git status跟踪新文件或暂存已修改的文件
git add filename
git add .提交更改
git commit -m “Commit message”查看提交历史
git log
分支管理
列出所有分支
git branch -a创建新分支
git branch new-branch-name切换分支
git checkout branch-name创建并切换到新分支
git checkout -b new-branch-name合并分支
git merge source-branch删除分支
git branch -d branch-name
远程操作
查看远程仓库
git remote -v推送更改到远程仓库
git push origin branch-name从远程仓库拉取最新内容
git pull origin branch-name
撤销更改
撤销工作目录中所有未暂存的更改
git checkout .将文件回退到上一个提交的状态
git checkout HEAD^ filename重置暂存区到最近一次git commit的状态
git reset
git reset –hard HEAD
高级操作
交互式暂存
git add -i查看特定文件的修改历史
git log -p filename暂存当前工作进度
git stash
git stash pop使用变基代替合并(谨慎使用)
git rebase master
Github实用CheatSheet
http://pafl.top/2024/03/26/Github实用CheatSheet/