To install git follow the instructions mentioned in the below url for Windows, Linux and Mac OS.
https://www.atlassian.com/git/tutorials/install-gitOnce the installation is done please follow the basic configuration as mentioned below.
1) check git version > git --version
2) configure username > git config --global user.name = "your name"
3) configure email > git config --global user.email = "your email"You are ready to go !!!
this commands gives you the installed version of the git in your machine.
To create a directory
mkdir <directory name>
To Change the directory
cd <directory name>
Converts a directory into a local git repository.
git init - converts a directory into a git repositoryTo add a single or muiltiple files to staging area
git add fileName or git add .
To commit the changes in the local repository.
git commit -m "commit message" To list the status of the files in staging area.
git status To configure the global username and email id
git config --global user.name = "Shubham"
git config --global user.email - "Shubham@gmail.com"
git config user.name = "Shubham"
git config user.email = "shubham@gmail.com"To connect a local repository to a specific remote repository.
git remote add origin <ssh url>
git remote add origin https://github.com/shubhamkushwah123/DevOps.gitTo Clone a remote git repository into a local git repository.
git clone <repo name>
git clone https://github.com/shubhamkushwah123/DevOps.gitTo Pull the changes from master branch of the remote git repository.
git pull origin master To Push the changes to master branch of the remote git repository.
git push origin master To List all the branches
git branchTo create a new branch
git branch $branchNameTo delete an existing branch
git branch -d $branchNameTo merge a child branch to master
git merge $branchNameTo save the changes, when they are not in state of commit.
git stashTo stash changes and clearing up the directory
git stash -uTo List the stashes created.
git stash listTo get the stashed work back.
git stash applyTo get the context and history of logs of a repository
git logTo Copy and Store a set of commit outside of our repository.
git rebaseTo revert back to the previous version of the file.
git revert