1. What is Version Control System and its Types
2. What is Git?
3. What is GitHub?
4. And the difference between the two.
-
VCS or version control
- is a management system
- that tracks changes in a computer file.
-
It is a software tool that records and manages changes
- to the source code over a period of time.
Q. imagine that you are working with your friend on a shared document and two of you are making changes in the file at the same time, what will happen? How will you track the change and mark the owner of the same? Or maybe you are working in a large team, how will you manage then?
- It helps developers to work efficiently.
- rollback and revert files back to a previous state or
- revert the entire project back to a previous state,
- compare changes over time,
- see who last modified something that might be causing a problem,
- who introduced an issue and when, and more, .
Basically there are three major types of VCS.
- Local Version Control Systems
- Centralized Version Control Systems
- Distributed Version Control Systems
official Link to Dowload
-
Git is one of the most popular Version Control System.
-
Git was originally developed in 2005 by the creator of Linux.
-
Git is free and open-source software so, anyone can use it.
GitHub
- is one of the most advanced and developed hosting platforms
- for version control and collaboration.
- It is a web-based service for version control using Git
- has all the benefits of git and even more.
Set user name and email – Git
- git config --global user.name "Your Name"
- git config --global user.email [email protected]
To confirm it
-
change like adding / deleting etc.
- it's history will save in "git repository" named ".git"
-
how do we get this folder ?
- git init - initialize an empty git repository (means folder)
cd "FolderLocation" ~ Change Directory
ls ~ Show all file in directory (Not the hidden once)
ls -a ~ Show all hidden file (files start with ".")
ls ".FolderName " ~ Show what folder contians.
touch "FileName.Extension" ~ create file
git status ~ what are the changes made in the project which is not currently saved in terms of record
~ tells about the changes which are not in the history of your project
~ show untracked file
- Untracked File (Red File) ~ like "Main.java" above means they are in "Staging Area"
git add "."(all untracked file) or "FileName"(particular file) ~ Save untracked file history in git repositry
green file like "main.java" above means they are at stage Area and now we can commit.
git commit -m "message" ~ allow to write description about last last tracked files.
~ and show which type of change occur
############################################################################
- above status means there is no untracked file and all you changes are recorded
vi "FileName.Ex.." ~ view, write and modify the file content
press "esc" and then press ":x" to exit
cat "FileName.Ex.." ~ only show the file content in terminalgit
#############################################################################
- above status shows modification in file
git restore --staged ~ used to unstage
git restore ~ to discard changes in working directory
git log ~ used to view the history
rm -rf <FileName> ~ used to remove file
- you can not directly remove a commit from anywhere
- for remove it, unstage them upto that commit you want to remove
- from top to bottom
- copy the commit id just below it
- use "git reset <commit id>" to unstaged changes after reset those commit
now the other are go to unstaged area
- Don't want to commit and don't want to lose these changes
- use "git stash"
- basically want you to go back stage and
- when ever I want you I bring you back
- use "git stash pop"
- not committed and in the saperate structure ( at back stage)
- To remove them
- Use "git stash clear"
git - means git
remote - means you are working with url
add - add a new url
origin - name of the url
- To share the changes at that url
- Use "git push origin master"
Where,
- origin - url name
- master - branch
"ssh-keygen -t ed25519 -C [email protected]" ~ generate pulic and private key pair
"clip < ~/.shh/id_ed25519.pub" ~ Clip SSH Keys to clipboard (so you can paste SSH Keys anywhere after it directly)