GitLab Basics
- GitLab - Squashing Commits
- GitLab - Rebase Operation
- GitLab - Add a File
- GitLab - Create a Branch
- GitLab - Fork a Project
- GitLab - Create Project
- GitLab - SSH Key Setup
- GitLab - Git Commands
- GitLab - Installation
- GitLab - Introduction
GitLab Users and Groups
GitLab Issue Tracker
- GitLab - Wiki Pages
- GitLab - Milestones
- GitLab - Referencing Issues
- GitLab - Merge Requests
- GitLab - Create Issue
GitLab Instance Management
GitLab Continuous Integration
- GitLab CI - Container Registry
- GitLab CI - Cycle Analytics
- GitLab CI - Advanced usage of CI
- Configuring GitLab Runners
- GitLab CI - Permissions
- GitLab - CI/CD Variables
- GitLab - CI/CD
- GitLab CI - Introduction
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
GitLab - Git Commands
Description
Git commands are used for sharing and combining the code easily with other developers.
Git Commands
Following are the some basic Git commands can be used to work with Git −
The version of the Git can be checked by using the below command −
$ git --version
Add Git username and email address to identify the author while committing the information. Set the username by using the command as −
$ git config --global user.name "USERNAME"
After entering user name, verify the entered user name with the below command −
$ git config --global user.name
Next, set the email address with the below command −
$ git config --global user.email "email_address@example.com"
You can verify the entered email address as −
$ git config --global user.email
Use the below command to check the entered information −
$ git config --global --pst
You can pull the latest changes made to the master branch by using the below command −
$ git checkout master
You can fetch the latest changes to the working directory with the below command −
$ git pull origin NAME-OF-BRANCH -u
Here, NAME-OF-BRANCH could be master or any other existing branch.
Create a new branch with the below command −
$ git checkout -b branch-name
You can switch from one branch to other branch by using the command as −
$ git checkout branch-name
Check the changes made to your files with the below command −
$ git status
You will see the changes in red color and add the files to staging as −
$ git add file-name
Or you can add all the files to staging as −
$ git add *
Now send your changes to master branch with the below command −
$ git push origin branch-name
Delete the all changes, except unstaged things by using the below command −
$ git checkout .
You can delete the all changes along with untracked files by using the command as −
$ git clean -f
To merge the different branch with the master branch, use the below command −
$git checkout branch-name $ git merge master
You can also merge the master branch with the created branch, by using the below command −
$git checkout master $ git merge branch-nameAdvertisements