Skip to content

My Short Path for Creating a Gitlab Project

Many times i want to quickly create a project in my Gitlab repo while creating new plugin/script for WordPress.

These command line instructions safe a lot of time by skipping the time to login, looking for changes in the interface, creating new project, selecting options (like remove the Readme at the beginning), etc. TBH i copied them from the Gitlab site just for my own purposes here. Like a notes.

You can also upload existing files from your computer using the instructions below.
Lets presume that you already have Git global setup and added a ssh key to your repo. Check this link if you got the message Permission denied – here

git config --global user.name "Your name"
git config --global user.email "[email protected]"

Create a new repository

If you start writing code and at a later stage you decide if it is worth uploading it to git repositories. Use only dash or underscores for the project names.

git clone [email protected]:your-gitlab-user/project-name.git
cd project-name
git switch --create main
touch README.md
git add README.md
git commit -m "add README"
git push --set-upstream origin main

Push an existing folder (if you already have an empty project)

Sometimes i firstly create an empty Gitlab project first because i don’t remember the sequence and commands

cd existing_folder
git init --initial-branch=main
git remote add origin [email protected]:your-gitlab-user/project-name.git
git add .
git commit -m "Initial commit"
git push --set-upstream origin main

Push an existing Git repository

I never tried this :)

cd existing_repo
git remote rename origin old-origin
git remote add origin [email protected]:your-gitlab-user/project-name.git
git push --set-upstream origin --all
git push --set-upstream origin --tags

I will be happy if someone finds this article useful. Happy codding.

Views: 8

Leave a Reply

Your email address will not be published. Required fields are marked *