Git 常用命令记录
git config user.name // 查看用户名
git config user.email // 查看邮箱
git config --global user.name “name” // 修改用户名
git config --global user.email “email” // 修改邮箱
git config --global core.longpaths true // 解决文件名太长问题
git clone url -b branch // 拉取指定分支代码
git branch // 查看本地分支
git branch -r // 查看远程分支
git branch branch_name // 新建一个本地分支
git branch -d branch_name // 删除一个本地分支
git branch -D branch_name // 强制删除本地分支
git checkout branch_name // 切换本地分支
git status . // 查看当前分支代码状态
git add . // 添加当前分支所有修改
git add file_path // 添加单独文件的修改
git commit . // 提交所有 add 的文件到本地临时仓
git commit -s // 提交代码,并编辑提交信息
git commit --amend // 提交修改代码到最近一次 commit 上,可修改提交信息
git pull // 拉取当前本地分支关联的远程分支的代码
git pull origin branch_name // 拉取远程分支的代码
git pull --rebase origin branch_name // 拉取相关远程分支代码,并进入 rebase 过程
git rebase --continue // 继续 rebase 过程(下一步)
git push origin local_branch:origin_branch // 推送到远程分支,origin_branch 可以直接命名新分支,并会在远程仓生产新分支
git reflog // 查看本地git操作历史记录
git reset --hard commit_id // 回退本地代码到某一节点
git clean -d -f && git reset --hard HEAD // 清理本地仓,并回退本地代码到最新节点
git log // 查看commit 记录
git show // 查看最近一次 commit 记录
git show commit_id // 查看某一次 commit 记录
1万+

被折叠的 条评论
为什么被折叠?



