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

Git

Uploaded by

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

Git

Uploaded by

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

Git:

----
-> Git is version control system that helps to track changes in code.
-> The advantages of git over others are
1.Popular
2.Free and open source
3.fast and scalable

-> Github allows developers to store and manage their code using Git.

Repository:
-----------
-> A Git repository is a central storage location for managing and tracking changes
in files and directories.
-> Repositories are of 2 types
1.public - visible to all
2.private - only visible to collabarators

->We can initialize the repository by adding a README file while creating a
repository.
->This README gives the discription about our project.

Commit:
-------
-> A modify or update a file we need to commit the file.

How to configure Git in your local machine:


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

git config --global user.name "My name" - used to set username

git config --global user.email "[email protected]" - used to set email

git config --list - used to view all the configurations

Basic commands:
---------------
1. clone - cloning a repository on our local machine.

eg: git clone <-some link->

2. status - displays the status of the code.

eg: git status


3. add - adds new or unchanged files in your working directory to the Git staging
area.

eg: git add <-file name->

4. commit - It records the change.

eg: git commit -m "some message"

5. push - upload local repository to the remote repository.

eg: git push origin main


Initialize a folder or directory:
---------------------------------
1. git init

2. git remote add origin <-link->

3. git remote -v

4. git branch

5. git branch -M main

6. git push origin main

Git workflow:
--------------
Github Repository
|
clone
|
changes
|
add
|
commit
|
push

Git branches:
-------------
-> A project may have multiple modules so each module uses a different branch
inorder to maintain code .
-> After completion of the entire project we merge all the branches.

git branch - use to view in which branch we are in

git branch -M "name" - rename a branch

git checkout <-branch name-> - navigate to other branch

git checkout -b "branch name" - create a new branch

git checkout -d "branch name" - deletes a branch

git merge "branch name" - merges two branches

Pull request:
-------------
-> It lets you tell others about changes you have pushed to a branch in repository
on Github.
-> It is one of the way to merge branches.

You might also like