This is a step-by-step guide to set up a new project from scratch on GIT, which also includes initializing GIt on your local project.
These are the steps you need to follow:
1. The first step is to Login to your GIT account.
- Click on the “+” icon in the upper right corner and select “New Project.”
- Choose Private option
- Open the terminal and run commands
2. Initialize the project on GIT by hitting this command in the CLI of your project directory
git init
3. Add GitLab Repository as Remote origin
git remote add origin
4. Verify the Remote to ensure the remote origin added correctly, Run this command
git remote -v
5. To add all files of your project to repository, run this command
git add .
6. To check the status of the repository, run
git status
7. Now once all these things are done, commit your changes
git commit -m “Initial commit”
8. If you have already set up the project on the GIT, there is already a key generated and you might have the SSH key stored in a file on location /home/your_username/.ssh/id_rsa. But if it isn’t then generate an SSH key on the terminal by running this command
ssh keygen
Response like following key generation
Generating public/private rsa key pair.
Enter the file in which to save the key (/home/webner/.ssh/id_rsa):
/home/username/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter the same passphrase again:
Your identification has been saved in /home/webner/.ssh/id_rsa
Your public key has been saved in /home/webner/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:*************************************
*******@****-****-*********
The key’s randomart image is:
+—[RSA 3072]—-+
| .. BoB|
| . .. o B.|
| . o.. o|
| . . *.. ..|
| + +ES .o|
| o o *.+ .o|
| o ..=..o . o.|
| ..o oo +.+ o|
| … .+o+oo.|
+—-[SHA256]—–+
9. Open the following file on the terminal by using the cat command. And paste the key which you found in this file and paste it into your GIT account. Go to the edit profile->SSH Keys and save this.
cat /home/username/.ssh/id_rsa.pub
10. Now remember you have committed the changes to your local repository and you need to push them to the branch/remote repository by running following the command.
git push -u origin master