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"
Create New Repository
git init
Add and Commit Files
git add .
git commit -m "Added project files"
- 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
You may see:
modified: index.html
modified: style.css
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
or
git push
Check Current Status
git status
See Commit History
git log
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
- 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)