git命令

拉取远程分支

bash 复制代码
git pull

拉完分支我开始工作了,开始对项目改改改。

改好了,准备推送上去。

先确认哪些文件被修改了,以免遗漏,或误加文件(没遇到过)

bash 复制代码
git status

然后将所有修改的文件推送到暂存区,先存着,注意add后有点啊。

bash 复制代码
git add .

要是只想提交特定的文件,就指定一下文件

bash 复制代码
git add src/main.js

提交到本地仓库,m就是message消息的意思

bash 复制代码
git commit -m "修复登录bug"

推送到远程服务器

bash 复制代码
git push

不出意外就有意外了,远程服务器给我拒了,中英文翻译一下。

翻译:

  • error: failed to push some refs to 'https://gitlabXXXXXXXXXXXt':错误:无法将一些引用推送到 'https://gitlabXXXXXXXXXXXt'
  • hint: Updates were rejected because the remote contains work that you do not have locally.:提示:更新被拒绝,因为远程仓库包含你本地没有的提交。
  • hint: This is usually caused by another repository pushing to the same ref.:提示:这通常是因为另一个仓库推送到了同一个分支引用。
  • hint: If you want to integrate the remote changes, use 'git pull' before pushing again.:提示:如果你想合并远程的更改,请先执行 git pull 再重新推送。
  • hint: See the 'Note about fast-forwards' in 'git push --help' for details.:提示:更多细节请参阅 git push --help 中的 "Note about fast-forwards"。

好,听它的,拉取最新代码。

bash 复制代码
git pull

如果要拉dev分支用git pull origin dev

然后界面出现

翻译:

  • Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch.:请输入一条提交信息,说明这次合并的必要性,尤其是当你要把更新后的上游分支合并到某个主题分支时。
  • Lines starting with '#' will be ignored, and an empty message aborts the commit.:以 # 开头的行会被忽略,如果提交信息为空,则会中止这次提交。

先按esc键盘,再输入:wq命令,再enter键

bash 复制代码
按 Esc 键确保退出编辑模式。
输入 :wq (:命令, write保存, quit退出)。
按 Enter 回车

好了,再推送

bash 复制代码
git push
相关推荐
武昌库里写JAVA1 天前
SpringBoot+Vue 项目介绍
java·javascript·git·sql·ai
Hvitur3 天前
Git - 多分支合并
git·github
考虑考虑3 天前
git刷新远程分支列表
git·后端·gitlab
AI大模型-小华4 天前
Codex 自动测试怎么用?从生成测试用例到修复失败用例
git·测试用例·ai编程·软件开发·codex·chatgpt pro·codex cli
七分辣度4 天前
GitHub/Git 常用命令及使用场景
git·github
慧都小项5 天前
MyEclipse Inline Diff 实用指南:逐处核对 AI 修改再提交
git·ai编程·myeclipse·java 代码审查·ai 代码修改
德育处主任5 天前
让 Claude Code 在你睡觉时接着干活:tmux、权限策略与验收清单
git·ai编程·命令行
为思念酝酿的痛8 天前
Git基本操作
git·github
wno7049 天前
常用的Git命令清单
大数据·git·elasticsearch
真上帝的左手9 天前
3. 代码管理-Git-进阶
git·源代码管理