What is Git
Git is a distributed version control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files. Its goals include speed, data integrity, and support for distributed, non-linear workflows.
What is GitLab
GitLab is a web-based DevOps lifecycle tool that provides a Git-repository manager providing, issue-tracking and continuous integration and continuous delivery (CI/CD), using an open-source license, developed by GitLab Inc.
Create an account on GitLab
After Successfully register now Sing in
Create a new project on GitLab
After Successfully Project setup it’s like the above image.
Git Command
Step 1: Download git from
https://git-scm.com/downloads
Step 2: check git version in your machine
git –version
Step 3: Set global user
git config –global user.name “”
check user
git config --global user.name
git config --global user.email ""
check email set in global
git config --global user.email
Now check list of global
git config --global --list
Step 4: Create a project in your system
Step 5: Open terminal in mac or open cmd or git bash
Now, go to inside for folder which folder you want to upload on gitlab.
example:
cd /Applications/MAMP/htdocs/project_name
Now init git
git init
after, hit command you can check hidden file within folder to hit command
ls -a
Now, just put inside the folder any file example
touch index.html
Check git status
git git status
git add .
git commit -m "index.html file"
git remote add origin [email protected]:username/project_name.git
git push origin -u master
Step 6: Now check gitlab file is there or not.
git fork
the fork is a clone. It emerged because you cannot push to others’ copies without their permission. They make a copy of it for you (fork), where you will have write permission as well.
Step 1: Login your account and go to your project
Step 2: Select your project and click on fork
if you get the message No available namespaces to fork the project.
then click on groups->yourgroup from the menu and create a new group
Now, again come to project and click on the fork than you can select fork now you can check here groups are available
copy of the project we can merge with the original project
Now click on merge request(Sidebar section) you can check in sidebar
click on new marge request here source and the target branch
SSH KEY:
benefits of ssh if we have set up one time we don’t need to put username and password again and again.
Step 1:
First time using git.
git init
git remote add origin [email protected]:siddharth01992/tutorailgitlab.git
git add.
git commit -m “update file‘
git push origin master
Git global setup
git config --global user.name "username"
git config --global user.email "[email protected]"
Create a new repository
git clone [email protected]:username/tutorailgitlab.git
cd tutorailgitlab
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Push an existing folder
cd existing_folder
git init
git remote add origin [email protected]:username/tutorailgitlab.git
git add .
git commit -m "Initial commit"
git push -u origin master
Push an existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin [email protected]:username/tutorailgitlab.git
git push -u origin --all
git push -u origin --tags
How to Generate ssh key in mac
ssh-keygen -t rsa -C "[email protected]" -b 4096
pbcopy < ~/.ssh/id_rsa.pub
Automatically copy via terminal( Paste code in the text area)
Paste the key in Textarea automatically filled in the title.
How to Generate ssh key in ubuntu (for one time for one account)
ssh-keygen -t rsa -C “[email protected]” -b 4096
xclip -sel clip < ~/.ssh/id_rsa.pub
Same step as an above.
How to share a git repository
Setting->Members->add member
How to clone from branch
git clone -b saurabh https://gitlab.com/siddharth01992/laravel.git
After change push ur code.
git push origin saurabh