Git Basics: Version Control Where Clients Must Synchronize Code With A Server Before Creating New Versions of Code
Git Basics: Version Control Where Clients Must Synchronize Code With A Server Before Creating New Versions of Code
Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.
distributed version control, also known as distributed revision controlor decentralized version control, is a form of version control that
allows software developers to work on a given project without requiring them to share a common network.
Git is the most commonly used version control system today and is quickly becoming the standard for version control.
Git is a distributed version control system, meaning your local copy of code is a complete version control repository.
These fully-functional local repositories make it is easy to work offline or remotely. You commit your work locally,
and then sync your copy of the repository with the copy on the server. This paradigm differs from centralized
version control where clients must synchronize code with a server before creating new versions of code.
Git basics
Every time you save your work, Git creates a commit. A commit is a snapshot of all your files at a point in time. If a
file has not changed from one commit to the next, Git uses the previously stored file. This design differs from other
systems which store an initial version of a file and keep a record of deltas over time.
Commits create links to other commits, forming a graph of your development history . You can revert your code to a
previous commit, inspect how files changed from one commit to the next, and review information such as where and
when changes were made.
Branches
Each developer saves changes their own local code repository. As a result, you can have many different changes based
off the same commit. Git provides tools for isolating changes and later merging them back together. Branches, which
are lightweight pointers to work in progress, manage this separation. Once your work created in a branch is finished,
merge it back into your team’s main (or master) branch.
Git Commands:
git commit: Move all the staging area files into local repository.
git status
3)git status : This command returns the current state of the repository
if there are no changes it’ll return nothing to commit, working directory clean.
4) git commit : move all files from staging area to local rep.
ex : git log
ex : git branch
12 ) git checkout -b : Checkout and create a new branch with that name
13 ) git merge : combines the changes from one branch to another branch.
16) git giff --staged : diff of what is staged but not yet commited
18) git show head : Display the latest commit details, along with differences of the previos
version
19) git show head~1: Display the 2nd latest commit details, along with differences of the
previos version
20) git reset : Reset A Specific Commit. On the commit-level, resetting is a way to move the
head of a branch to a different commit.
22) git reset head~1 :head will move backwards by one commits.
23) git reset hard : move the files from staging area to tracted/untracted area. working will
get effected if any changes made in the file
24 ) git checkout <commitid> : to see the previous version of the files (move the commit
head to specified commit point.)
25) git checkout master : move the commit head to latest commit in the master branch.
26) git reflog: Display all the operations performed on local rep.