DEV Community

Guru prasanna
Guru prasanna

Posted on

Git Lab - Commands

Refer - https://docs.gitlab.com/topics/git/commands/

1. Create project

  • Go to GitLab.
  • Click on New Project → Create Blank Project.
  • Copy the GitLab repository URL.

2. To change visibilty of project from private to public

Project --> Settings --> General --> Visibility, project features, permissions --> Change to Public --> Save changes

3. To create a local copy of a remote repository

git clone <repository-url>

To get that repository-url

project --> Code --> Clone with HTTPS

Image description

To show the status of the working directory and staged files

git status

--> The git status command is used to check the state of your working directory and staging area.
--> It shows which changes are staged, unstaged, or untracked.

4. To create a blank document

touch blank.txt

5.To add the file to staging area

git add

git add . can be used to add to stage all changes (new, modified, or deleted files) in the current repository directory.

6. To unstage a file that was added to the Git staging area using git add

git restore --staged <filename>

7. To commit staged changes to the repository.

git commit -m " "

A commit message is entered inside double quotes to describe the changes.

8. To upload committed changes from your local repository to a remote repository

git push

To Configure Git if you forget userid/password of git

git config --global user.name "Your Name"  # Set your name
git config --global user.email "your-email@example.com"  # Set your email

Enter fullscreen mode Exit fullscreen mode

9. To pull Changes from Remote to local

git pull

10. To create a new branch

git branch <branch-name>

11. Switch to the new branch

git checkout <branch-name>

12. To display a list of commits in chronological order

git log

13. To find differences between the working directory and the last committed version

git diff

Using difference we can also Compare Two Commits

-->Commit id can be taken using git log

git diff <commit1> <commit2>

Top comments (0)