0% found this document useful (0 votes)
13 views

Manager: Xyz Abc Xyz

Git Notes By Sappal Sir

Uploaded by

Sandeep Sappal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Manager: Xyz Abc Xyz

Git Notes By Sappal Sir

Uploaded by

Sandeep Sappal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Git

Known as software configuration management system or source code management system

In software industry, while developing applications different programmers work on

different module, so we have to decide which programmer work on which module and assign

the task to programmer.

Before SCM this was perform manually.

Means TL/Manager used to assign the task to each programmer and collect it manually.

MANAGER

1 2 3 4

It was very difficult for manager to check and find out bug from task even its very difficult to check

whether programmer completed their task or not.

To eliminate the above drawback, we can use SCM system for versioning the work.

xyz
xyz
abc

1.0 & 1.1

Two types of code management

1] Centralized control system

2] Distributed version control system

Centralized version control system (CVCS)


Repository
commit

Working Copy Working Copy Working Copy

PC-1 India PC-2 US PC-3 China

In CVS all programmers submitted their work in central repository, so that manger can easily track all
the work done by programmers easily.

Each user checks the code of other users, how they are working, even they can track each other.

If PC1 Completed work A & PC2 Completed work B

Then next work will be C & D which will continue by PC1, PC2 and PC3

Distributed Version Control System (GIT)

- Developed by Linus Torvalds 2005


- Work on Linux version software tool
- Use for local repository system
- GitHub is used for remote server(Microsoft)
- In distributed version control system every contributor has a local or clone of the main
repository i.e. everyone maintains a local repository of their own which contains all the files
& metadata present in main repository. If anyone changes the code it will reflect to all the
user.
push push
Repository
pull pull
push pull

Local Local Local


Repository Repository Repository
update update update

Working Space Working Space Working Space


PC-1 PC-2 PC-3

CVCS

In CVCS a client needs to get local copy of source from server, do the changes and commit those
changes to central source on server.

CVCS system are easy to learn & setup

Working on branches is difficult in CVCS for developer after faces merge conflict.

CVCS system do not provide offline access

CVCS is slower as every command need to communicate with server

If CVCS server down developers cannot work.

DVCS

In DVCS, each client can have a local branch as well, and have complete history of their commits.

Client needs to push their changes to local branch which will be then push to server repository.

DVCS system is difficult for beginners’ multiple commands needs to be remembered.

Working on branches is easier in DVCS developers to eliminate conflicts.

DVCS system are working fine on offline mode a client copies the entire repository on their local
machine.
DVCS is faster as mostly user deals with local copy and communicate with server when necessary

If DVCS server is down, developer can work using their local copies.

Git Commands

-Update linux

yum update -y

-Install git

yum install git -y

Check Version

git –version

Configure git

git config –global user.name <username>

git config –global user.email <user email>

To check the configuration

git config –list

:q for exit

To create git workspace

Create a folder

mkdir punegit

change directory to punegit using

cd punegit

and run command

git init

it will create following git structure


Now programmer can write his programs in working space

After writing programes programmers can add their programs in staging area

Using command

git add <filename/path>

Use git status command to check the uncommited files

git status

will show the all the untrack files( those files which are not commited yet)

to move untrack files int staging area one can use

git add <filename>/path

to move file from staging area to Local Repository use command

git commit -m <message>

To show all the commits one can use

git log –[oneline]

To show particular commit one can use

git show <commit id>


To Connect with Centralized Repo Use following commands
git remote add origin
https://github.com/SandeepSappal/learndevops.git

To transfer data from local repo to centralized repo

git push -u origin main


[email protected]

.gitignore
Contains those files details or information
which are not part of git project
Process:
Vi .gitigonre
*.css
*.java
c*.cpp
sandeepfile
git add .
git commit “ my git ignore”

How to Create New Branch

- git branch <branch name>


to create a new branch

- git checkout <branch name>


use to change the branch

- git branch
will show the current branch
- git merge <branch name>
will merge the files of specified branch in master
- git branch <branch name> -d [-D forcefully]
delete the branch

Git Reset

git reset –hard

remove files after git add

means form work space and stagging area

Git Stash

Suppose you are implementing a new feature for your product, your code is in progress and suddenly
a customer escalation comes because of this, you have to keep aside your new feature work for few
hours.
You cannot commit your partial code and also you cannot throw away your changes, so you need
some temporary storage to safely store your previous work and later on you can retrieve your work
from that temporary storage as per your requirements.

Commands

git stash

git stash list

git stash apply stash@{0}

git stash clear

Git revert

The revert command helps you undo an existing commit

It does not delete any data in the process instead rather it creates a new commit with the
included files reverted to their previous state so, your version control history moves forward. While
the state of file moves backward.

reset before commit

revert after commit

Git commit - m ‘code’

Git log – oneline

Git revert <commit id>

Git Tags
Tag operations allows you to assign meaning full names to
specific version in the repository
To apply tags
git tag -a <tagname> -m “message” <commit id>

To see the list of tags


git tag

To see particular commit content by using tag


git show <tagname>

To Delete a tag
git tag -d <tagname>
Git Clone
It creates local repo automatically in Linux machine with the
same name as in GitHub account.

git clone <GitHub repo URL>

You might also like