Push existing folder to GitLab

Viewed 24135

In Gitlab project from the instructions, they tell how to add an existing_folder to Git repository. But after I press git commit the console open a vim.

Then how can I go to the last one git push -u origin master and push my repository to gitlab.

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

The command git commit launches your default command line text editor because a commit needs a message describing what is happening in it. There are two ways to add this message:

  1. When the editor (vim) is launched, write a commit message in the editor, then save and close the file. This message will now be stored with the commit. Exiting without saving the file will cancel the commit.
  2. Use the command git commmit -m "Commit message here", which allows you add a short commit message in the quotes without launching the editor.

A commit message can be anything, but here is an article if you want to go in depth on what should be in a message and how to format it. Sometimes I use the full text editor to write a complex message, sometimes I just need a quick note and use the inline command with the -m flag.

Want to change the default editor git uses for commit messages? You're in luck! Simply add it to your git config like this: git config --global core.editor "nano". Now commit messages will be opened in nano, or whatever editor command you put in this config command.

Change git commit to

git commit -m "insert commit message here"

The -m flag adds as a commit message whatever you enter in the quotation marks. The vim opens because the message is missing.

Related