This guide will walk you through setting up Git globally, creating a new repository, and managing existing folders or repositories.
Set your global Git username and email. Replace 'Your Name'
and 'your.tu-mail@tudelft.nl'
with your actual name and email.
git config --global user.name "Your Name"
git config --global user.email "your.tu-mail@tudelft.nl"
Clone the repository and create a new branch named ‘main’. Replace 'git@gitlab.tudelft.nl:your_directory/your_repository.git'
with your actual GitLab repository URL.
git clone git@gitlab.tudelft.nl:your_directory/your_repository.git
cd your_repository
git switch -c main
touch README.md
git add README.md
git commit -m "add README"
git push -u origin main
Navigate to your existing folder and initialize it as a Git repository. Add all files, make an initial commit, and push the changes to the ‘main’ branch. Again, replace 'git@gitlab.tudelft.nl:your_directory/your_repository.git'
with your actual GitLab repository URL.
cd existing_folder
git init --initial-branch=main
git remote add origin git@gitlab.tudelft.nl:your_directory/your_repository.git
git add .
git commit -m "Initial commit"
git push -u origin main
Navigate to your existing Git repository, rename the existing ‘origin’ to ‘old-origin’, add a new ‘origin’, and push all changes and tags to the new ‘origin’. Again, replace 'git@gitlab.tudelft.nl:your_directory/your_repository.git'
with your actual GitLab repository URL.
cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.tudelft.nl:your_directory/your_repository.git
git push -u origin --all
git push -u origin --tags
Remember to replace all placeholders with the appropriate values for your specific use case.