GIT
What is Version Control Systems?
Version control is a system that records changes to a file or set of files over time so that you can recall specificversions later. For the examples in this book, you will use software source code as the files being versioncontrolled, though in reality you can do this with nearly any type of file on a computer
What is Git?
The most widely used modern version control system in the world today is Git. Git is a mature, actively maintained open source project originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel.
GIT Step By Step
1.Create a folder in the system
2.initialize git for converting this folder as local repository
command:git init
3.create a file a.c in that folder
command:touch a.c
4.check the status of git
command: git status
5.Now the file a.c is in cached stage to save
6. Add the file a.c into git
command:git add a.c
7.Save the file a.c into git repository
command:git commit -m "firt commit"
8.To see the log in the git
command:git log
9.to set your account's default identity.
Omit --global to set the identity only in this repository.
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
or
git config --global --edit
10.To revert to old stage before commit:
usage do any chage in the file before adding to git you can use below command to revert
Command:git stash
11.To revert to old stage after commit:
command: git log to get id of the commit
for example:commit 74a462a173204fa5f4791af577926e65d4d882d6
Author: Majo Joseph <mmm@gmail.com>
Date: Thu Apr 25 10:34:41 2019 +0530
first commit
command to revert:git revert 74a462a173204fa5f4791af577926e65d4d882d6
12.To delete commited file
command:git rm -r a.c
git commit -m "deleted"
13.To add repository to githum
1.Create one id in github.com
2.Login to that id.
3.Create repository
4.Add that repository using below command
command: git remote add origin https://github.com/majo/FOSS.git
5.Add local repository to remote using below command
command: git push -u origin master
or
command:git push --set-upstream origin master -To avoid using branch name now you can just type git push to
to push all the doc.
14. To remove added repository
To list:
command:git remote -v
command: git remote remove origin
Branching and Merging
1.Create new branch
command: git branch abc
2.To see all the branches
command: git branch
3.Switching new branch
command:git checkout abc
4.To switch to previous branch
command:git checkout -
5.Merging new branch
command:git merge abc master
6.Addming files to new branch where origin is the remote reposiory added name where origin is the name in refer 13-4 step.
command:git push origin <newbranchname>
Comments
Post a Comment