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
相关推荐
mister_guo1 天前
开发指南:Git日常维护与常用命令
git
鶴哥只手遮天1 天前
Git 2.56 源码深度剖析:为 Git 3.0 铺路的架构重构
git·开源
小此方1 天前
「插曲:Git」标签管理篇:理解Tag标签、为指定提交打标签、查看标签详情与附注标签
git
Madison-No71 天前
多语言聊天大模型--测试报告
linux·git·python·selenium·jmeter·自动化·postman
小此方1 天前
「插曲:Git」多人协作篇:远程分支创建与关联、多人协作冲突解决、Feature分支开发与合并、git remote prune清理失效分支
git
可乐ea1 天前
Git 基础设施重建:智能体规模开发下的读写解耦
大数据·git·elasticsearch·分布式存储·git基础设施·智能体规模开发·读写解耦
信可维1 天前
AI 说「改完了」怎么确认真改完了:git diff + 测试 + 一张验收表的 3 步复核
人工智能·git
Sun子矜2 天前
Git+Gitee 新手教程精简归纳版
git·gitee
亿道电子Emdoor2 天前
【Perforce】Klocwork-kwgcheck图形化界面无法打开如何解决
git·python·github