将现有文件夹推送到 GitLab

问题描述

在 Gitlab 项目的说明中,他们告诉了如何将 existing_folder 添加到 Git 存储库。 但是在我按下 git commit 后,控制台会打开一个 vim。

那我怎么去最后一个git push -u origin master把我的仓库推送到gitlab。

cd existing_folder
git init
git remote add origin [remote url]
git add .
git commit
git push -u origin master

解决方法

命令 git commit 启动您的默认命令行文本编辑器,因为提交需要一条消息来描述其中发生的事情。有两种方法可以添加此消息:

  1. 启动编辑器 (vim) 后,在编辑器中写入提交消息,然后保存并关闭文件。此消息现在将与提交一起存储。退出而不保存文件将取消提交。
  2. 使用命令 git commmit -m "Commit message here",它允许您在引号中添加简短的提交消息,而无需启动编辑器。

提交消息可以是任何内容,但here is an article if you want to go in depth on what should be in a message and how to format it。有时我使用全文编辑器来编写复杂的消息,有时我只需要快速记录并使用带有 -m 标志的内联命令。

想要更改 git 用于提交消息的默认编辑器吗?你很幸运!只需将它添加到您的 git 配置中,如下所示:git config --global core.editor "nano"。现在提交消息将在 nano 或您在此配置命令中放置的任何编辑器命令中打开。

,

将 git commit 更改为

git commit -m "insert commit message here"

-m 标志会将您在引号中输入的任何内容添加为提交消息。由于消息丢失,vim 打开。