Getting started with Git
What is Git?
Git is a distributed revision control and source code management system with an emphasis on speed. Git was initially designed and developed by Linus Torvalds for Linux kernel development.
The core of Git was originally written in the C, but Git has also been re-implemented in other languages, e.g., Java, Ruby and Python.
Git has the functionality, performance, security and flexibility that most teams and individual developers need.
How it works:
A Git repository contains the history of a collection of files, If you clone a Git repository, by default, Git assumes that you want to work in this repository as a user. Git also supports the creation of repositories targeting the usage on a server.

Basic Git commands:
To use Git, developers use specific commands to copy, create, change, and combine code. These commands can be executed directly from the command line or by using an application like GitHub Desktop or Git Kraken.
some common commands for using Git:
git init initializes a brand new Git repository and begins tracking an existing directory. It adds a hidden sub folder within the existing directory that houses the internal data structure required for version control.
git clone creates a local copy of a project that already exists remotely. The clone includes all the project’s files, history, and branches.
git add stages a change. Git tracks changes to a developer’s code base, but it’s necessary to stage and take a snapshot of the changes to include them in the project’s history.
git commit saves the snapshot to the project history and completes the change-tracking process. In short, a commit functions like taking a photo. Anything that’s been staged with git add will become a part of the snapshot with git commit.
git status shows the status of changes as untracked, modified, or staged.
git branch shows the branches being worked on locally.
git checkout :
- To checkout from one branch to another eg: git checkout <branch name>
- To discard changes of a particular fire before add eg: git checkout<file>
git merge merges lines of development together. This command is typically used to combine changes made on two distinct branches. For example, a developer would merge when they want to combine changes from a feature branch into the master branch for deployment.
git pull updates the local line of development with updates from its remote counterpart. Developers use this command if a teammate has made commits to a branch on a remote, and they would like to reflect those changes in their local environment.
git push updates the remote repository with any commits made locally to a branch.
How it looks :

Some advanced Commands:
$ git stash :
Saved working directory and index state WIP on master:
2dfe283 Implement the new login box
HEAD is now at 2d465es Implement the new login boxgit branch -v -a: To see all branches local as well as origin.
master f9b16aa5 [behind 302] Merge branch 'development'
development 3f781289 forgot pswd updated
remotes/origin/dev1 90x93ww1adfe Change version
remotes/origin/dev2 8d1wx9be61 bug resolve
remotes/origin/fun2 3f7w1128x9 forgot pswd updated
Undo pushed commits:
You can revert individual commits with:
git revert <commit_hash>Undo a Git merge:
git reset --hard commit_sha1Git stash list:
git stash listGit stash or Git stash save, actually created a Git commit object with some name and then save it in your repo.So it means that you can view the list of stashes you made at any time.
Git stash pop:
It deletes the stash from the stack after it is applied. If you want a particular stash to pop you can specify the stash id.
References:
http://rogerdudler.github.io/git-guide/
Hope you got some useful things about Git .
If you enjoyed the article try to give some claps and share it :)
