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

Git Sheet

Git is a widely used open-source distributed version control system that allows developers to manage source code and track changes efficiently. It supports collaboration among multiple developers working from different locations and provides features like code integration, backup, and non-linear development through branching. The document also outlines the setup process for Git and GitHub, basic commands for operations, and the management of repositories and branches.

Uploaded by

Dhavan Ravuri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Git Sheet

Git is a widely used open-source distributed version control system that allows developers to manage source code and track changes efficiently. It supports collaboration among multiple developers working from different locations and provides features like code integration, backup, and non-linear development through branching. The document also outlines the setup process for Git and GitHub, basic commands for operations, and the management of repositories and branches.

Uploaded by

Dhavan Ravuri
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Source Code Repository Tools (or) Version Control Softwares

What is Git?

‘’Git’’ is a go-to-version control tool that allows developers to access all of the code and
efficiently manage their source code and track file changes be it small, medium, or
massive application development. It remains the most widely used open-source
distributed version control system (DVCS) till date.

-> Multiple developers will work for project development.

-> Developers will be working from multiple locations .

-> All developers code should be store at one place (Code Integration Should
Happen) .

-> To integrate all the developers source code at one place we will use
Sourcecode Repository Softwares.

Advantages with Source code repository sofwares

1) All the developers can connect to repository server and can integrate the
code.

2) Repository server will provide monitored access

- Who

- When

- Why

– What.
•Git is used to tracking changes in the source code hence tracks history

•Git is a distributed version control tool for source code management. It is free and
open-source.

•Git creates backup automatically, as the developer has a version of the code on the local
repository.
•Git allows multiple developers to work together; hence is scalable and supports
collaboration.

•Git supports non-linear development because of its thousands of parallel branches.

Environment Setup to work with Git Hub


1) Create Github account ( www.github.com ) 2) Download and install Git Client software
( https://git-scm.com/downloads ).

3) Once installation completed, right click on the mouse and verify git options display (If
git options displaying our git client installation completed successfully).

Working with GitHub


-> Login into github account with your credentials

-> Create Repository in github Note: Repository is used to store project source code.
Every Project will have one repository

-> When we create a repository, unique URL will be generated with Repository Name (i.e
Repo URL)

-> All the developers will connect to repository using Repository URL

-> We can create 2 types of Repositories in Git Hub

1) public repository

2) private repository

-> Public Repository :- means everybody can access but we can choose who can modify
our repository

-> Private Repository :-means we will choose who can access and who can modify.

Working with Git Bash

-> Git Bash we can use as Git Client software to perform Git Operations

-> Download and install git client (https://git-scm.com/downloads)

-> Right Click on Mouse and choose "Open Git Bash Here"

git help : It will display frequently used git commands git help

<command-name> : It will open documentation for given command


Configure Your Email and Name in GitBash with Commands
$ git config --global user.email [email protected]

$ git config --global user.name "name"

$ git init : To initialize our folder as git working tree

$ git clone : To clone git repository to our machine from github.com

Syntax : $ git clone <project-repo-url>

$git pull:- this command is used to take code from our repository.

$ git status : It will display staged , un-staged and un-tracked files Syntax :

Staged Files : The files which are added for commit

Un-Staged Files : The files which are modified but not added for commit

Un-tracked files : Newly created files Note: To commit a file(s), we should add
to staging area first how to unstaged files from staging area

$git restore --staged mydemo.java

$ git add : It is used to add file(s) to staging area Syntax :

$ git add <file-name>

$ git add .

$ git commit : It is used to commit staged files to git local repository

Syntax : $ git commit -m 'reason for commit'

$ git push : To push changes from git local repository to git central repository

Syntax : $ git push

Steps to push code to github central repository

1) Create one public repository in git hub (take github repo url)

2) Clone github repository using 'git clone' command $ git clone 'repo-url'

3) Navigate to repository folder

4) Create one file in repository folder $ touch Demo.java


5) Check status of the file using 'git status' command $ git status (It will display
as untracked file)

6) Add file to staging area using 'git add' command $ git add .

7) Commit file to git local repository $ git commit -m 'commit-msg'

8) Push file from git local repository to git central repository using 'git push'
command $ git push

Branches
> Branches are used to maintain seperate code bases for our project

-> In GiT repository we can create multiple branches like main,


master,dev,qa..etc

GROUP CHANGES: Commands for Git branching

You can decide how to group the changes to create meaningful commits.

$ git branch

Lists all local branches in the current repository

$ git branch [branch-name]

Creates a new branch

$ git checkout [branch-name]

Switches to the specified branch and updates the working directory

$ git merge [branch]

Combines the specified branch’s history into your current branch

$ git branch -d [branch-name]

Deletes the specified branch

$ git fetch remote <branchname>

Fetches a branch from the repository


$ git push –all

Pushes all local branches to a designated remote repository

Cheat sheet in one shot


------------------------------------------------------------------

You might also like