After creating new project with gitlab api, e.g.:
curl --fail -d '{"name":"test","default_branch": "master"}' -H "Content-Type: application/json" -X POST https://repo.**.com/api/v4/projects?access_token=<your access token> --output project_details.json
You could assume your new project url based on post data name
-> https://repo.**.com/<gitlab user or gitlab group>/test.git
or you could parse response json with some tool, e.g. python:
http_url_to_repo=$(python -c "import json; print(json.load(open('project_details.json'))['http_url_to_repo'])")
Then you could follow new project instruction for existing folder:
#Push an existing folder
cd existing_folder
git init
git remote add origin $http_url_to_repo
git add .
git commit -m "Initial commit"
git push -u origin master
Where existing_folder
is folder with your source files which you want to upload as a commit to new gitlab project.