Why Only Git?
• Speed:- Snapshots concept
• Parallel branching:- Multiple branches at a time unlike other SCM tools
• Fully Distributed:-
1. Backup copy is available in multiple locations.
2. No need Internet connection. So no network latency.
3. No need central server separately.
4. Each workspace will have its own repo internally.
5. Can create any no of branches.
6. Can share code without using central repo.
7. That’s why we call GIT as DVCS (Distributed Version Control System).
SVN:-Central Version Control System
Git:- Distributed Version Control System
Snapshots
1. Get any previous version (Backup).
2. Represents some data of a particular time.
3. Stores the changes(appended data) only. Not a whole copy.
Commit
1. Store changes in repo (Will get commit ID).
2. 40 Alphanumeric characters.
3. Concept Checksum (It’s a tool in Linux generates binary value equal to data present in file).
4. Even if you change one dot, Commit ID will be changed
5. Track the changes
Git Stages
• Workspace
• Physically see file & Modify
• Staging/Indexing area
• Buffer area
• Takes snapshot
• Repository (Local)
• Store changes locally
• Repository (Central)
• Store changes Centrally.
Types of Repositories
• Bare Repositories (Central)
• Store & share only
• All central repositories are bare repositories
• Non-Bare Repositories (Local)
• Where you can modify the files.
• All local repositories are non-bare repositories.
Basic Git Commands :-
Initialize an existing directory as Git repository
# git init
Clone a repository that already exists on Github, including all of the files, branches and commits
# git clone [repo_url]
After using the git init command, link the local repository to an empty GitHub repository
# git remote add origin [url]
SETUP CREDENTIALS:-
Set a username
# git config --global user.name “[firstname lastname]“
Set an email address
# git config --global user.email “[email address]“
STAGE & SNAPSHOT:-
Show modified files in working directory, staged for your next commit
# git status
Add a file as it looks now to you next commit (stage)
# git add [file-name]
Add all changed files to staging area
# git add .
Commit your staged content as new commit snapshot
# git commit -m “[message]“
Transmit local branch commits to the remote repository branch
# git push origin <branch-name>