What is Version Control System?
The most obvious benefit of using revision control is the ability to have an unlimited number of people working on the same code base, without having to constantly send files back and forth.
There are two types of Version Control System
- Centralized Version Control System.
- Distributed Version Control System.
Major three types of Centralised Version Control System
- CVS(Concurrent Version Control System):- No clone, pull, push, local branches are possibl in it.
- SVN(Subversion Control Sytem):- No local branches.
Major three types of Distributed Version Control System
CREATING FIRST REPOSITORY
Go to the dashboard of git and click on the + sign which is there in right side at the top.Click on new repository.
Give your repository name and description as per your choice. Then, you can choose public or private repository. Public is free but private is paid. Then click on create repository.
Once repository is created. lets create a directory in the system. let say i am here creating it in home folder by name maths.
mkdir maths cd maths git init touch README.md
After that, add content to the file named “project” using any editor like vim, gedit.
This command creates an empty Git repository – basically a
.git directory with subdirectories in it.
there are two types of repository.
- local repository.
- remote repository.
git add README.md
git add adds your modified files to the queue to be committed later. Files are not committed.
This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit.
The “index” holds a snapshot of the content of the working tree, and it is this snapshot that is taken as the contents of the next commit. Thus after making any changes to the working tree, and before running the commit command, you must use the
add command to add any new or modified files to the index.
git commit -m "maths project"
git commit commits the files that have been added and creates a new revision with a log… If you do not add any files, git will not commit anything. You can combine both actions with
git commit -a
git remote add origin https://github.com/amisha2016/maths.git git push -u origin master
git push pushes your changes to the remote repository.
remote = remote repository. Stuff that’s on your hard drive is local. Stuff that’s on GitHub’s server is remote. origin = the default name of the remote repository on GitHub corresponding to the repo you’re currently in on your machine. master = the default name of the initial branch of a repository. So, “origin master” is the default branch of your repository on GitHub. That’s why you do
git push origin master to update GitHub based on the changes you committed locally.
The command git remote add origin “git remote add origin https://github.com/amisha2016/maths.g” creates a new remote called origin located at “git remote add origin https://github.com/amisha2016/maths.git”
. Once you do this, in your push commands, you can push to origin instead of typing out the whole URL.
Remotes are simply an alias that store the url of repositories.
It means “git push https://github.com/amisha2016/maths.git master” and “git push origin master” are same thing.
What is Pull Requests?
Pull requests help you collaborate on code with other people. It lets you tell others about changes you’ve pushed to a GitHub repository. Once a pull request is sent, interested parties can review the set of changes, discuss potential modifications, and even push follow-up commits if necessary.
lso, a conflict will only ever handicap yourself. It will not bring your complete team to a halt or cripple your central repository. This is because, in Git, conflicts can only occur on a developer’s local machine – and not on the server.