Comprehensive guide on managing GitLab repositories over HTTPS using the command line
Note: Make sure you have Git installed on your machine and have correctly set up access to your
GitLab repository via HTTPS.
1. Clone a Repository:
To clone a
GitLab repository over HTTPS, use the
git clone
command followed by the HTTPS URL of the repository. Replace
https://gitlab.com/username/repo.git
with the URL of your
GitLab repository.
git clone https://gitlab.com/username/repo.git
You will be prompted to enter your
GitLab credentials (username and password or token) to authenticate.
2. Login with a Personal Access Token (Optional):
If you prefer to use a personal access token instead of your password to access
GitLab over HTTPS, you can create one in your
GitLab account settings. To use the token for authentication, run the following command:
git clone https://<your-access-token>@gitlab.com/username/repo.git
Replace
<your-access-token>
with your actual personal access token.
Before making any changes, configure your Git identity with your name and email address. This information will be associated with your commits.
git config --global user.name "Your Name" git config --global user.email "youremail@example.com"
Replace "Your Name" and "
youremail@example.com" with your actual name and email.
4. Make Changes to the Repository:
Navigate to the cloned repository directory using the
cd
command and start making changes to your code.
cd repo
Use standard Git commands to make changes, such as
git add
,
git commit
, and
git push
. For example:
git add . git commit -m "Add new feature" git push origin master
5. Pulling Changes:
To retrieve the latest changes from the remote repository, use the
git pull
command.
git pull origin master
6. Create a New Branch:
To create a new branch in your repository, use the
git checkout -b
command.
git checkout -b new-branch
7. Switch Branches:
You can switch between branches using the
git checkout
command.
git checkout existing-branch
8. Merge Branches:
To merge changes from one branch into another, use the
git merge
command.
git checkout destination-branch git merge source-branch
9. View Repository Status:
To see the status of your repository, including untracked files and changes not yet committed, use the
git status
command.
git status
10. Log of Commit History:
To view the commit history, use the
git log
command.
git log
These are the fundamental Git commands for managing repositories on
GitLab over HTTPS using the command line. Remember to replace placeholders with your actual information and adapt these commands as needed for your specific workflow.