DEV Community

Vigneshwaran V
Vigneshwaran V

Posted on

Gitlab basic Commands

Today i learned about gitlab and i installed it. and also learn how to upload the projects in it by using the commands in terminal like git init,
git add ., git commit -m, git push.

First Time Setup

git config --global user.name "Your Name"
git config --global user.email "your@email.com"
Enter fullscreen mode Exit fullscreen mode

Create New Repository

git init
Enter fullscreen mode Exit fullscreen mode

Add and Commit Files

git add .
git commit -m "Added project files"
Enter fullscreen mode Exit fullscreen mode
  • This command tells Git: Prepare these files to be saved, It moves changed files into the staging area,

Example

Suppose you changed: index.html, style.css.
Now Git sees them as modified, but not ready to save yet.
If you run:

git status
Enter fullscreen mode Exit fullscreen mode

You may see:

modified: index.html
modified: style.css
Enter fullscreen mode Exit fullscreen mode

so now you run => git add .

Here: git add → add files to staging.
. → means all files in current folder.

Push Code

git push -u origin main
Enter fullscreen mode Exit fullscreen mode

or

git push
Enter fullscreen mode Exit fullscreen mode

Check Current Status

git status
Enter fullscreen mode Exit fullscreen mode

See Commit History

git log 
Enter fullscreen mode Exit fullscreen mode
  • git add --- Add a specific file to staging area

  • git commit -m "message" --- Save changes with a message

  • git log --- View commit history

  • git push --- Upload commits to GitHub/GitLab

  1. A branch in Git is like a separate workspace or copy of your project where you can work independently without affecting the main project.

Why Branches Are Used

  • Develop new features safely.

  • Fix bugs.

  • Test ideas.

  • Work with teams without breaking the main code.

Top comments (0)