Creating a New Repository
Root Repository or Master Branch
To create a new repository, click "Create a project".
You can create a repository under your username or under a group. For now just enter a Respository name and a Description under the Blank project tab.
Initializing a new repository will look like this:
copy url for project: https://gitlab.com/user-name1/test.git
The README file can be created with your project. It's optional and can be added later if necessary. Mostly, if you're creating a new repo you'll want to initialize it with a README. If you already have a repo you're wanting to upload you can skip this step. The README can be used in various ways, but it will allow you and others to clone the project immediately.
Now that we've setup your GitLab account and created a new repository, navigate to your project folder through the command prompt or Git Bash and type:
This will create a hidden directory where Git operates.
Next type:
git status
This will show you the status of your repository and also we can use it to verify Git has initialized correctly.
Next save these Git commands to notepad as a text file.
Command line instructions
Git global setup
git config --global user.name "Robert Jakob"
git config --global user.email "[email protected]"
Create a new repository
git clone https://gitlab.com/user-name1/test.git
cd test
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Existing folder
cd existing_folder
git init
git remote add origin https://gitlab.com/user-name1/test.git
git add .
git commit -m "Initial commit"
git push -u origin master
Existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.com/user-name1/test.git
git push -u origin --all
git push -u origin --tags
Now type, git status. You should see a message showing an untracked file...
To tell Git to start tracking changes made to this file, we need to add it to the staging area by using git add.
Now using git status, you should see the "new file". The files added are now in the Staging Area. They have not been committed to the repository. So we can add and remove these files before storing them in the repository.
To store our staged changes we run the commit command with a message describing what we've changed.
When adding multiple files you can use a wildcard '*' to add them simultaneously.
git add '*.txt'
Similarly, you can commit multiple files simultaneously.
To see all the changes that have been committed use git log.
To map a remote repository to your local git config use: git, remote add, the remote name, and the repository url.
git remote add main https://gitlab.com/user-name1/test.git
note: it's usually a good idea to name your main repo something obvious like master, main, root, origin, etc...
For more information on git config:
https://www.atlassian.com/git/tutorials/setting-up-a-repository/git-config