Sign in and create a new account at GitLab
Once you account is setup create a new project.
You can do this either in your account at the gitlab site, or on the command line.
Using The Command Line
First set your global Git credentials on your local machine
git config --global user.name "Rick"
git config --global user.email "[email protected]"
The Git username is not the same as your GitLab username.\ The Git username is used to show who did what in git - such as commit or merge.\ The GitLab username is the namespace used in git commands to access your remote repo.
Create a local repo from an existing local folder
cd to_existing_folder
git init
git remote add origin https://gitlab.com/ubiquity/grokthis.git
git add .
git status
git commit -m "initial commit to local repo"
git push -u origin master
If there are conflicts you will need to do a pull and edit the conflicts. i.e. if you created the new repo on the GitLab site and the remote readme.md file conflicts with the local version. The vscode editor is integrated with git to help you resolve these conflicts.
git pull origin master
Edit to resolve the conflicts and then stage the readme file (add it to the local staging area)
git add readme.md
git commit -m "fixed readme conflicts"
git push -u origin master
Commit puts the modified file into the local staging area. push uploads your local repo (master branch) to the gitlab repo (origin).
Using push with the -u option links this local branch with the remote branch. It makes it so you can use git pull without any arguments. It sets origin as the upstream remote in your git config.
Add a new file to the repo
git add .gitlab-ci.yml
git commit -m "Add .gitlab-ci.yml"
git push origin master
Remove files from repo (make sure they are in .gitignore)
git rm -r --cached *.pyc
You can also create a new local repo by cloning an existing remote repo
git clone [email protected]:ubiquity/mindflow.git
cd mindflow
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
This information is from: GitLab Help
You can create a new repo locally without going to GitLab to manually create a new project and then push the repo. If you have access to that namespace, a new project will be created under that GitLab namespace with its visibility set to Private by default (you can later change it in the project’s settings).
This can be done by using either SSH or HTTP:
## Git push using SSH git push —set-upstream [email protected]:namespace/nonexistent-project.git master
## Git push using HTTP git push —set-upstream https://gitlab.example.com/namespace/nonexistent-project.git master
With my namespace:
git push —set-upstream https://gitlab.com/ubiquity/grokthis.git master
When the push finishes, a message will show the command to set the remote and the URL to the new project:
The private project namespace/nonexistent-project was created.
To configure the remote, run:
git remote add origin https://gitlab.example.com/namespace/nonexistent-project.git
To view the project, visit:
https://gitlab.example.com/namespace/nonexistent-project.git