Get Started

We'll launch our Command shell first to get started with Git. Git bash, which is included with Git for Windows, can be used on Windows. The built-in terminal is available for Mac and Linux.
Now introduce yourself to Git. This is critical for version control systems, because each Git commit relies on it:
git config --global user.name "name" git config --global user.email "name@email.com"
To create and initialize git, create a folder either using the Graphic User Interface or Terminal by using this command
mkdir mysitecd mysite
Initialize git in that project by running the following command:
git init
You can utilize Git help if you're having problems remembering commands or options for commands. The help command can be used in a variety of ways in the command line:
git -help
or
git help --all

Adding and Committing new file(s)

You've just established your first Git repo locally. It is, however, empty. Let's start by adding some files or creating a new file in your favorite text editor. Then save or move it to the newly created folder.Then we check the Git status and see if it is a part of our repo:
git status
To start tracking (stage) the file or all files use
git add filename
or
git add .
We're ready to move from stage to commit for our repo now that we've done our work. As we work, adding commits allows us to keep track of our progress and modifications. Each commit is treated as a "save point" by Git. It's a time in the project where you can go back and fix a bug or make a modification.
git commit -m "your message"

Branching

A branch is a new/different version of the main repository in Git. We're working in our local repository since we don't want to disrupt or maybe destroy the main project. As a result, we create a new branch named newbranch:
git branch newbranch
Checking out a branch is done with the command checkout. From the current branch to the one given at the command's end:
git checkout newbranch
To list all the branches using the command:
git branch
To create and move into a branch, use the following command:
git checkout -b newbranch
To merge branches, go to the branch you wish to join to first, then use the command merge to combine it to the current branch:
git checkout mastergit merge newbranch
newbranch will be merged into master
To delete a branch, using the following command
git branch -d newbranch
Click any of the links below to learn more about git.
The list is just a selection of the great Git documentation; try searching online for additional sites to discover which one you like.
badge