I have many local git repos on my OSX. Using the command line I want to make new gitlab repositories on https://gitlab.companyname.com
from existing local repositories.
Is it possible to do that?
To create a new repo, you'll use the git init command. git init is a one-time command you use during the initial setup of a new repo. Executing this command will create a new . git subdirectory in your current working directory.
After creating your account in GitLab, go to your Projects page and click New project. From the Blank project tab, give the project a name and add a description. If you want it to be a public repository, click the Public option. Make sure the Initialize repository with README option is left unchecked.
--set-upstream
Assuming you'll take care of writing the script that would do the following for each of your local repo, it seems that as of Gitlab 10.5 you can simply use
# To your own domain git push --set-upstream address/your-project.git # To gitlab.com with SSH git push --set-upstream [email protected]:username/new-repo.git master # To gitlab.com with HTTP git push --set-upstream https://gitlab.example.com/username/new-repo.git master
This will create a new project on Gitlab without you creating it manually on the server
Push to create a new project
When you create a new repository locally, instead of manually creating a new project in GitLab and then cloning the repository locally, you can directly push it to GitLab to create the new project, all without leaving your terminal. If you have access rights to the associated namespace, GitLab automatically creates a new project 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 HTTPS:
## Git push using SSH git push --set-upstream [email protected]:namespace/nonexistent-project.git master ## Git push using HTTPS git push --set-upstream https://gitlab.example.com/namespace/nonexistent-project.git master
You can pass the flag
--tags
to thegit push
command to export existing repository tags.Once the push finishes successfully, a remote message indicates the command to set the remote and the URL to the new project:
remote: remote: The private project namespace/nonexistent-project was created. remote: remote: To configure the remote, run: remote: git remote add origin https://gitlab.example.com/namespace/nonexistent-project.git remote: remote: To view the project, visit: remote: https://gitlab.example.com/namespace/nonexistent-project remote:
Create new empty projects in GitLab for each of your local repos you want to push to GitLab. After you create the project's, you will be taken to the default project page.
Then cd into each of your existing git repos. Do a git remote add origin <your new gitlab repo address>
And then a git push -u origin master
You will need to do this for each of your repos you want to add.
Your repo address is given to you on the project page. As http and/or ssh. If you already have a remote called origin on your local machine, you might want to rename it first. Or you can call the gitlab one something different. Also if you want to push all your branches to gitlab you can do a git push --all origin
If you want your tags, git push --tags origin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With