## Important: Change {username} to your GitLab username
git push --set-upstream git@gitlab.com:{username}/djangoku.git master
Pushing to GitLab
So far we have only worked locally. In this chapter we will create a remote repository on GitLab to push our code to.
Creating the GitLab project
GitLab has the functionality to create a new project by non-existant repositories by just pushing to them. The repository is set to private by default. You can change that in the GitLab project settings.
If you feel more comfortable to use the GitLab website, that’s fine too. Just make sure the remote repository is empty, so we can push to it without pulling it first and maybe even running into merge conflicts. |
This command created the project on GitLab and pushed the current state of our local repository to the remote repository. However, it did not add the the remote repository.
So, let’s do this:
## Important: Change {username} to your GitLab username
git remote add origin git@gitlab.com:{username}/djangoku.git
Creating a Readme file
Since our project is still missing a Readme file, now is finally the time to create one. Feel free to add any content you want to the Readme file. Do not add any sensitive data to it, as it will be tracked by Git and may be exposed to the public.
Create a Readme.md file:
echo "# djangoku" > Readme.md
This blog post by Raphael Campardou lists what makes a good readme file. |
Commit and push updates
If you run git status
you will see, that we added Readme.md.
Now we can stage, commit and push it to GitLab:
git add .
git commit -m "Add Readme 🐌"
git push origin master
Checklist
✔︎ Remote repository is added
git remote -v
→ Shows origin
with url as fetch and push remote.
✔︎ Remote repository is up to date
git diff origin/master
→ Outputs nothing.