Welcome to Git for beginners blog, Hope you are doing well and staying home and staying safe, Here is git cli blog
what is git -
Git is 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 file. Its goals include speed, data integrity ,and support for distributed non linear workflows.
How to install Git
Go to the Git Website
Getting started -
This is a folder inside your project where git tracks all the changes made in the files and build a history reference over time. In your project the git repository folder you will see a .git folder.
To create a folder : mkdir Hello
To create a file: touch index.html style.css
To delete a file : rm index.html
To see inside a folder : ls (Ls)/ dir
To move up a folder : cd ..
To delete a folder : rmdir Hello
To go in any folder : cd
To get started with Git, go to your terminal and run the following command in your project directory.
To set your user name and email in the main configuration file.
git config –global user.name “robin”
git config –global user.email “firstname.lastname@example.org”
Git init –
To initialise a git repository for a new or existing project.
Get into root directory and type following command.
Git clone is a git command line utility which used to target an existing repository and create a clone , or copy of that target repository , also sets the remote to original source so that you can pull again.
git clone <git url to clone>
To check the status of files you’ve changed in your working directory
To add changes to your working directory so that git can index those files.
git add .
To add all changed files to git or
Just type “git add filename”
This command is use for to commit changes you have made and sets it to new commit object for your remote
git commit -m”your message”
Git Pull / Push-
This command is use for push or pull your changes to remote . If you have added and committed your changes and you want to push them and if your remote has updated and you want those latest changes.
git pull<remote><branch> and
Git Branch –
It will list out all of the branches
git branch -a
to list remote branches as well.
Git checkout –
To switch between different branches.
git checkout <branch name> or
git checkout -b<branch name>
Git Stash –
To save changes that you don’t want to commit immediately.
git stash apply
in your working directory.
To merge two branches you are working
First checkout the branch into which you want to merge other branch and then type
git merge <name_other_branch>
This will list all of the commits you have made into working directory this shows the history of commits with their ids and information.
To revert the changes to last commit.
To check what remote/ source you have or you want to add a new remote
git remote and git remote add <remote_url>