Git
Git is a distributed version control system (VCS) for tracking changes in computer files and
coordinating work on those files among multiple people.
Version control system is a system that records changes to a file or set of files over time so
that you can recall specific versions later. Unlike a central VCS, a distributed VCS has both remote
and local repositories. As a result, it does not require the backup.
- Download Git from https://git-scm.com
- Enter Configuration Values:
$ git config --global user.name "firstName lastName"
- your name
$ git config --global user.email "example@gmail.com"
- your email - Check Your Settings:
$ git config --list
To open a manual and display information about Git:
$ git help -a
or $ git help --all
- shows a list of all available commands
$ git help config
- explains how to use the Git verb, in this case, config
$ git help -g
or $ git help --guide
- shows a list of Git guides
To create a New Repository:
$ git init
To clone a Remote Repository:
$ git clone /Url/
To add / propose changes:
$ git add /file/
To add everything:
$ git add .
To remove:
$ git reset /file/
To commit changes:
$ git diff
- shows the changes made
$ git commit -m "Detailed message explaining the nature of changes"
To push changes to remote repository:
$ git pull origin master
$ git push origin master
Git project consists of three main sections:
- Working Directory
- Staging Area / Index
- HEAD
Three main states of files:
- Committed
- Modified
- Staged
A Git branch is a movable pointer to the commits. The default branch is called master.
To create a new branch:
$ git checkout -b newBranch
To remove a branch:
$ git branch -d newBranch
To go back to master:
$ git checkout master
To push to the remote repository:
$ git push origin /branch/
To merge a branch to current branch:
$ git merge /branch/
To see the commit that was just made:
$ git log
The message, author, email, and other additional information will be displayed.
$ git checkout -- /file/
or
$ git fetch origin
- to cancel all the commits implemented locally