- Git and Github are two different things.
- Git is the version control system.
- GitHub is a service for hosting Git repos that helps people collaborate on writing software.
- GitLab
- BitBucket
- A repository is usually used to organize a single project. Repositories can contain folders and files, images, videos, spreadsheets, and data sets -- anything your project needs. Often, repositories include a README file, a file with information about your project. README files are written in the plain text Markdown language.
-
By default, your repository has one branch named main that is considered to be the definitive branch. You can create additional branches off of main in your repository. You can use branches to have different versions of a project at one time. This is helpful when you want to add new features to a project without changing the main source of code.
-
Have you ever saved different versions of a file? Something like:
- story.txt
- story-edit.txt
- story-edit-reviewed.txt
Making and commiting changes
- Two ways
- Using git bash
- About this in command's section.
- Using github
- Give a demo.
- A commit is when you tell Git to save these staged changes.
-
When you open a pull request, you're proposing your changes and requesting that someone review and pull in your contribution and merge them into their branch.
-
Pull requests show diffs, or differences, of the content from both branches. The changes, additions, and subtractions are shown in different colors.
`@username`
- At the bottom of the pull request, click Merge pull request to merge the changes into main.
- Github forks local copy of a project folder/repository.
- You can make a relevant chanages ask the owner to review changes
- Markdown is a lightweight markup language that you can use to add formatting elements to plaintext text documents.
- Simplicity, Readability, Speed, Widely Supported
-
Heading
-
Bold Text
- bold Text
-
Italic Text
- Italic Text
-
Blockquote
Blockquote
-
Ordered List
- Item 1
- Item 2
-
Unordered List
- Item 1
- Item 2
-
Code
console.info('Block of code!')
-
Horizontal Rule
-
Link title
- Table
Sr. No | First Name |
---|---|
1 | John Cena |
2 | CM Punk |
-
Emoji
That is so funny! 😂
⚠️ Warning: Do not push the big red button. -
Fenced Code Blocks
{
"firstName": "John",
"lastName": "Smith",
"age": 25
}
- Syntax Highlighting
{
"firstName": "John",
"lastName": "Smith",
"age": 25
}
-
Heading IDs
-
Definition Lists
First Term : This is the definition of the first term.
-
Strikethrough
The world is flat.We now know that the world is round. -
Task List
- Write the press release
- Update the website
- Contact the media
-
Highlight
I need to highlight these ==very important words==.
-
Subscript & Superscript
H
2OX^2^
-
Comments
Here's a paragraph that will be visible.
-
Some things markdown does not support natively
-
underline
- will be underlined.
-
ident
- This is the first sentence of my indented paragraph.
-
center
- This text is centered.
-
Center this text
-
color
- This text is red!
-
Image size, image caption and more
-
- Windows: Download
-
Git directory
- Git stores everything it needs to accurately track the project.
-
Working directory
- User makes local changes to a project.
-
Staging area
- Information about what will go into your next commit.
- stash
To gain the ability to work simultaneously on multiple branches.
-
git worktree
-
workspace local checkout of your code also called as working tree or working copy or just checkout.
-
index staging area for all yours files changes to commit before commit.
-
local repository Your local .git directory.
-
upstream repository It's hosted some where on internet.
- Check git version
git -v
git --version
- Get git help
git -h
git --help
- To Know the username
git config user.name
- Set username
git config user.name "<username>"
- Set email
git config user.email "<email>"
- Set default branch name
git config --global init.defaultBranch main
- To Know the email
git config user.email
-
Git init
-
Create an empty Git repository or reinitialize an existing one
git init
-
Only print error and warning messages; all other output will be suppressed.
git init -q
git init --quite
-
Use the specified name for the initial branch in the newly created repository.
git init -b master
git init --initial-branch master
-
Specify the directory from which templates will be used. (See the "TEMPLATE DIRECTORY" section below.)
git init --template ./
-
use if repo will be shared with multiple users
--shared
-
-
Git clone
- Clone Repositories
git clone <repository_url> <directory_name>
- Clone Branch
git clone -b <branch_name> <repository_url>
-
Git add
-
Add file contents to the index
git add .
git add all
git add -A
git add filename
-
Don’t actually add the file(s), just show if they exist and/or will be ignored.
git add --dry-run README.md
-
Allow adding otherwise ignored files.
git add -f eg*.css
-
Record only the fact that the path will be added later. An entry for the path is placed in the index with no content.
git add -N eg*.css
-
Don’t add the file(s), but only refresh their stat() information in the index.
git add --refresh
-
-
Git status
git status
git status -s
git status --short
git status --long
git status --branch
git status --show-stash
git status --u all
-
Git commit
git commit -m "commit message"
-
If you want to add changes to the last commit (perhaps you forgot to include something), use --amend
git commit --amend
-
Git diff
- see diff between two commit
git diff <commit-hash> -- *filename.js
- see diff between two commit
-
Git branch
-
Create branch
git branch <branch-name>
-
list branch
git branch -l
git branch --list
-
delete branch
git branch -d <branch-name>
git branch --delete <branch-name>
-
rename branch
git branch -m <old-branch-name> <new-branch-name>
git branch -move <old-branch-name> <new-branch-name>
-
Change branch
git switch <branch-name>
git checkout <branch-name>
-
git remove/ rename
git rm <filename>
git mv <old-file-name> <new-file-name>
-
untrack files
git rm --cached <filename>
-
unmodify changes
git checkout --filename
git checkout -f