Friday, 2 October 2020

Gitlab Commands

When you create any project in Gitlab or Git then you can use below commands using shell/ command prompt to initialise and setup your source/version control 

First you have to to set it up the user name and login email id. Although when you create your first project in gitlab, you will see the Below commands but if you follow the instructions , you might get errors at some steps, I will provide details for those errors and how to fix those too.

Let's follow the below steps.

1. Git global setup
git config --global "<Your Name>"
git config --global "<your login email >"
2. Create a new repository
git clone<user_name>/<project name>.git
cd <your local project directory>
git add
git commit -m "add README"
git push -u origin master
3. Push an existing folder
cd existing_folder
git init
git remote add origin<user_name>/<project name>.git
git add .
git commit -m "Initial commit"
git push -u origin master
4. Push an existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin<user_name>/<project name>.git
git push -u origin --all
git push -u origin --tags
So, it might work for you always but for some Step 3 or 2 might throw below error.

remote: The project you were looking for could not be found.

fatal: repository '<user name>/<project name>.git/' not found

So, in order to resolve this, you need to modify the URL. You have to add your username in the domain as well . So it should look like 

https://<user_name><user_name>/<project name>.git

So replace the project URL in step 2, 3 and 4 if it doesn't work with default one.


Post a comment