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
相关推荐
゛凌乱的记忆づ16 小时前
好用的md文件编辑器——TyporaS与Typora
笔记·git·typora·markdown
এ慕ོ冬℘゜19 小时前
Git 基础规范:小步提交、提交信息规范与常用命令
git·svn
忘了ʷºᵇₐ20 小时前
Git学习笔记
笔记·git·学习
BIBI20491 天前
换 Git 托管平台怎么做?基于 TortoiseGit 的跨平台迁移教程
windows·git·tortoisegit·问题解决·版本控制·最佳实践
echome8882 天前
Git 日常救急:撤销提交、找回误删文件和解决冲突
git·版本控制
赵民勇2 天前
Git命令详解
git
不老刘3 天前
Antigravity 的 New Worktree 模式:给 AI 代理一个安全的“平行工位”
人工智能·git·ai编程·antigravity
光谱SpectrAI3 天前
Windows 也中招:Git Bash 和 Node 仍信任泄露的 eMudhra 证书
git
YIN_尹3 天前
【git原理与使用】git初识与安装
大数据·git·elasticsearch
Leo_Mr3 天前
Vue3 项目配置 Git 提交规范(企业通用方案:husky + commitlint + cz-git + lint-staged)
git