Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
157 views

Git Basics: Version Control Where Clients Must Synchronize Code With A Server Before Creating New Versions of Code

Git is a distributed version control system that allows developers to work simultaneously on a project without requiring a shared network. Each developer has their own local repository that contains the full version history. Developers commit changes locally and then sync their local repository with the central repository. Key features of Git include commits that create snapshots of files, branches for isolating work, and distributed collaboration through local repositories that sync with remote repositories.

Uploaded by

veeren
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
157 views

Git Basics: Version Control Where Clients Must Synchronize Code With A Server Before Creating New Versions of Code

Git is a distributed version control system that allows developers to work simultaneously on a project without requiring a shared network. Each developer has their own local repository that contains the full version history. Developers commit changes locally and then sync their local repository with the central repository. Key features of Git include commits that create snapshots of files, branches for isolating work, and distributed collaboration through local repositories that sync with remote repositories.

Uploaded by

veeren
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Git:

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.

In distributed version control Two levels of version controlling is going to happen.

1) First level of version controlling is happen at Local workstation ( Machine)


2) Second level vrersion controlling is happen at Centrol repository (Git Hub Server)

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.

Files and commits


Files in Git are in one of three states: tracted/untracted/modified (working copy), staged, or committed. When you first
modify a file, the changes exist only in your working directory. They are not yet part of a commit or your
development history. You must stage the changed files you want to include in your commit. The staging area contains
all changes that you will include in your next commit. Once you’re happy with the staged files, commit them with a
message describing what changed. This commit becomes a part of your development history.

Git Commands:

1) git init : It create empty repository.

This command turns a directory into an empty Git repository.

adding and committing files/directories is possible.


2) git add :Adds files in the to the staging area for Git.

Before a file is available to commit to a repository,

the file needs to be added to staging area.

Ex : git add file1 : move the file into staging area

git add . : move all tracted/untracted files into staged area.

git commit: Move all the staging area files into local repository.

ex : git commit -m ' any msg"

git status

This command returns the current state of the repository.

3)git status : This command returns the current state of the repository

If a file is in the staging area, but not committed,

it shows with git status. Or,

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 commit -m 'First commit'

5) git log : Display the log of local commits

ex : git log

git log -3 : display latest 3 commits information.

6) git config : to set repository related parameters value.

ex :git config --global user.email "sheshivardhan@yahoo.com"

ex :git config --global user.name "sheshi"


7) git branch : Display current branch name.

ex : git branch

8) git branch -d : To delete the branch.

git branch -d <branch_name>

ex : git branch -d test

9) git branch <branch_name> : to create new branch

git branch test

10)git branch -a : List all remote or local branches

11) git checkout :use git checkout to switch branches.

git checkout branch1

12 ) git checkout -b : Checkout and create a new branch with that name

git checkout -b branch12

13 ) git merge : combines the changes from one branch to another branch.

ex : git merge branch12 (Merge changes into current branch)

14) git rm : Delete the files from staging area

git rm file1 --cached

15) git diff : diff of what is changed but not staged

16) git giff --staged : diff of what is staged but not yet commited

17) git diff HEAD : working dir and rep

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.

This can be used to remove commits from the current branch.

ex : git reset <commit_id > : head will be moved to specific commit

git reset 8726ejhd

22) git reset head~1 :head will move backwards by one commits.

ex : git reset HEAD~1

git reset HEAD~2 (head will move backwards by two 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

git reset hard

24 ) git checkout <commitid> : to see the previous version of the files (move the commit
head to specified commit point.)

ex : git chekout 08933cjeg83hjsdklj

25) git checkout master : move the commit head to latest commit in the master branch.

ex : git checkout master

26) git reflog: Display all the operations performed on local rep.

You might also like