拉取远程分支
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