Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push existing folder to GitLab

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
like image 619
Thang Dang Avatar asked Jan 01 '21 07:01

Thang Dang


People also ask

Can I push a folder to GitLab?

In GitLab, create a project to hold your files. Visit this project's homepage, scroll down to Push an existing folder , and copy the command that starts with git remote add .

How do I turn an existing folder into a git repository?

git init Existing Folder For an existing project to become a Git repository, navigate into the targeted root directory. Then, run git init . Or, you can create a new repository in a directory in your current path. Use git init <directory> and specify which directory to turn into a Git repository.


1 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.

like image 63
RedBassett Avatar answered Sep 28 '22 02:09

RedBassett