8. (GDSC BMC)
@angeloseby | #gdscbmc
● Git is a free and open source distributed Version
Control System
● Can handle small to very large projects with speed
and efficiency
● Created by Linus Torvalds, launched April 7 2005
● Every Git working directory contains a repository
with complete history and full revision capabilities
● Git is local , not dependant of a network or a
central server
9. (GDSC BMC)
@angeloseby | #gdscbmc
Goals of Git
● Speed
● Non - linear development / Parallel branches
● Fully distributed
● Able to handle large projects efficiently
15. (GDSC BMC)
@angeloseby | #gdscbmc
git --help
@angeloseby | #gdscbmc
Git’s
documentation
is built in - try it
for yourself
16. (GDSC BMC)
@angeloseby | #gdscbmc
Setup the
workspace
@angeloseby | #gdscbmc
Make a folder
named ‘project’
in desktop of
your system
$ mkdir project // Make new folder
$ cd project // Change directory
c:/desktop/project> $
Goto Desktop -> Right Click -> Open Terminal Here
17. (GDSC BMC)
@angeloseby | #gdscbmc
Config git
@angeloseby | #gdscbmc
Set the email
and name for Git
to use when you
commit
/project> $ git config --global user.name "John Doe"
/project> $ git config --global user.email bugs@gmail.com
18. (GDSC BMC)
@angeloseby | #gdscbmc
Creating git repo
@angeloseby | #gdscbmc
Set the email
and name for Git
to use when you
commit
/project> $ git init
To create a new local git repo in your cd
This will create a .git directory in your cd
Then you can commit files in that directory into the repo.
/project> $ git clone url
To clone a remote repo into to your cd
This will create the given local directory, containing a working
copy of the files from the repo, and a .git directory
19. (GDSC BMC)
@angeloseby | #gdscbmc
git status
@angeloseby | #gdscbmc
View the status
of your files in
the working
directory and
staging area
/project> $ git status
To view the git status
It lets you see which changes have been staged, which haven't,
and which files aren't being tracked by Git.
/project> $ git status -s
To view the short version of git status
20. (GDSC BMC)
@angeloseby | #gdscbmc
Add a file
@angeloseby | #gdscbmc
Create a file in
your cd
Create a new text file in your in cd.
Write something in it 😃
21. (GDSC BMC)
@angeloseby | #gdscbmc
git add
@angeloseby | #gdscbmc
Add the files that
are created and
modified for
staging commit
/project> $ git add file name
To add a single file for staging commit
Now when check the git status you can see that the added file
is now added to the tracked files list
/project> $ git add .
To add all the files for staging commit
This will add all the new and modified files for staging to commit
22. (GDSC BMC)
@angeloseby | #gdscbmc
git reset
@angeloseby | #gdscbmc
Remove your file
from staging /project> $ git reset filename
To reset filename
Removes that file from staged files
23. (GDSC BMC)
@angeloseby | #gdscbmc
git commit
@angeloseby | #gdscbmc
Captures a
snapshot of the
project's
currently staged
changes
/project> $ git commit -m “Initial Commit”
To save a current version of repo we commit
This will commit (make a safe zone) with all the tracked /
staged files
-m stands for commit message , it can be any
meaningful message.
The statement in the quoted enclosed near to it is the
commit msg
24. (GDSC BMC)
@angeloseby | #gdscbmc
git diff
@angeloseby | #gdscbmc
To view the
difference
between files
/project> $ git diff
To view the difference between staged and unstaged files
To the view the difference between staged and last
committed file
/project> $ git diff --cached
25. (GDSC BMC)
@angeloseby | #gdscbmc
git log
@angeloseby | #gdscbmc
See the git
commit history
in command line
interface
/project> $ git log
To see the history of all git commits with message & author
To the view the shorter version of git history
/project> $ git log --oneline
26. (GDSC BMC)
@angeloseby | #gdscbmc
Amend a commit
@angeloseby | #gdscbmc
Edit the last
commit if you
forgot to add
some file
/project> $ git commit -amend
This will take all the files in the staging area and add it to the
last commit
29. @angeloseby | #gdscbmc
@angeloseby | #gdscbmc
/project> $ git branch name
Creates a new branch from current working branch with given name
30. @angeloseby | #gdscbmc
@angeloseby | #gdscbmc
/project> $ git checkout branch_name
Switch to the local branch with given branch name
If such branch doesn’t exist, creates a new branch with that name from the current
working branch
31. @angeloseby | #gdscbmc
@angeloseby | #gdscbmc
/project> $ git branch -d branch_name
/project> $ git branch -D branch_name
Both deletes a branch with given name
32. @angeloseby | #gdscbmc
@angeloseby | #gdscbmc
/project> $ git merge branch_name
Merges the branch with given branch name to the currently working branch