diff --git a/Git & Github Advanced/Fundamentals.md b/Git & Github Advanced/Fundamentals.md new file mode 100644 index 0000000..4ec994a --- /dev/null +++ b/Git & Github Advanced/Fundamentals.md @@ -0,0 +1,283 @@ +# Fundamentals +```git +git --version //for checking version +Example: git version 2.43.0 + +cd scripts //for changing directory + ls // view directories and files + rm // for remove file + git init // file or directory ---> to ---> version control system (git) +git status // check file condition : untracked or tracked or commited +git add ./ // for stagged (green) +git rm --cached // for unstage ( green --> red) +git commit -m "Addec Readme.md" // for save your file in directory +git restore readme.md // for backup deleted file in your repository, but without git init directory is not work command line but you can restore from recyclebin +git restore --staged readme.md // for unstage +git config --global user.name "technical Asthavi" // add user name of your repository +git config --global user.email "technicalasthavi@gmail.com" // add user email of your repository +clear // clear windows terminal commands +history // terninal give you all command list that you have uses in terminal + Note : if You have not available file for commit,Your Terminal says to you: " Your working tree is clean" +cd .. // for child directory to parrent directory +Note : if you have not uses git init command in directory , Terminal says : fatal: not a git repository (or any of the parent directories): .git +git branch // to see branches and * (star) is indicate you You are working here. +git checkout -b Dev // for Switched to a new branch "Dev" name +-----when you put command under Dev (Branch) : git status // Terminal say : On Branch Dev nothing to commit, working tree clean. and (-b ) use for new branch create. +-----ls // your all dir/file see in subdirectory (Dev) or main files or dir copy to Dev branch +-----vim from_Dev.txt --> This is a file in the Dev Branch -->esc --> :wq --> Back to Terminal +-----git status // On Branch dev from_Dev.txt --> untracked +------git add from_Dev.txt //stages --> git commit -m "added Dev file" --> + Next : --> git branch // to see branch + ex: *Dev + master +git checkout master// to move main branch // branch is a seperate line of branches +Note : sub branch is not copy your dir or file when you want to move parrent branch(master) + +git log --oneline // to see comment list with id and massages +and (HEAD -> master) is notify to you : you have recently added this commit + + +git checkout dev // to switched dev branch +or +git switch Dev // to switched dev branch + +git checkout -b staging // for create new branch (name = staging) and moved to new branch Staging + +for mergging branch : + +git merge dev // dev branch copy folder -- to -- master branch // that means main branch update by Dev Branch for commitable file // sure ! before this changes you must to switched master branch then try it. + +Access +1. Personal Access Token +2. SSH + +git remote -v // to varify your git repository is connected to GitHub // if yes : see in Terminal // if no: terminal give no any information. that means black . + +git remote add origin // for stablish connection with git Terminal to Github Repository + +again + +git remote -v // for see connection : + output : origin (fetch) + output : output : origin (push) + +git status +// on branch master +// nothing to commit, working tree clean + +git push origin master +// username for 'https://github.com' : put user name +// password for 'https://https://@github.com : put here personal acess token + +git remote -v // // for testing GitHub is connected with git +git remote set-url origin https://@github.com/username/repository name here.git // for many time use , no need to next time even use user name and password or don't ask you terminal nest time username and password. +clear// +git push origin master +// * [new branch] master -> master +// pushes Done by git on GitHub repository +########################################## + + +git pull origin master // github data to git that is called pull from master github + + +for github push : +vim from_local.txt +git add from_local.txt +git commit -m "added from local" +ls +git branch +git push origin master +// master -> master + +//Note : git pull is not use in another person repository because you should token of his repository. + +git remote -v // test +git clone +ssh-keygen // generating public/private ed2...9 key pair (for pair my repository to Another person repository) +//Enter file in which to save the key (/home/ubuntu/.ssh/id_ed25519): enter press then +/home/ubuntu/.ssh/id_ed25519 already exists. +Overwrite (y/n)? ^c (Ctrl + C) +cd .ssh +ls +authorized_key id_ed25519 id_ed25519.pub know_hosts known_hosts.old + +.ssh$ cat id_ed25519 +-----Begin openssh private key----- +aghshhshh...70(case form) +jsjhshshjbshshshsh..70 (case form) +aghshhshh...70(case form) +jsjhshshjbshshshsh..70 (case form) +aghshhshhhshhshehhdhdhdhjddh +-----End openssh private Key------- + +ssh$ ls +authorized_key id_ed25519 id_ed25519.pub know_hosts known_hosts.old + +ssh$ cat id_ed25519.pub +ssh-id25519 GSKGKGSKSKGKGDKGSKSKDGKDGKGKSGKS +A ubuntu@ip-172-31-34-159 // copy this code go github > profile> ssh and GPG KEYS >NEW SSH KEY: +TITLE: ANYNAME EX:BATCH-9-SERVER-KEY +KEY TYPE : ATHENTICATION +KEY : PASTE HERE YOUR COPY 🔑 KEY (EX: ssh-id25519 GSKGKGSKSKGKGDKGSKSKDGKDGKGKSGKS +A ubuntu@ip-172-31-34-159) + >Add ssh key +>go terminal: +ls +mkdir github_repo +cd github_repo/ +ls + +go github> choose and copy any person repository url (ssh ) +>go terminal: +git clone git@github.com:LondheShubham153/90DaysOfDevOps.git + +yes + +ls + +cd 90DaysOfDevOps +ls +vim Readme.md +😊 you 💘 +git status +o/p > on branch master +git diff// for changing in document +git add Readme.md +git status +git commit -m "added some changes" +git push origin master + + +# abhi hamne sikha ki kaise dusare ke repository ko clone kar sakte hai + +aayiye jante hai ki +2:07:39 + +github to github fork kiya jata hai clone karne ke liye + +repository choose kar le pahle + +git clone origin master //for self + +and that choose any file for modify +ex: Readme.md + +vim readme.md +this is readme file +esc +:wq + +git status +Readme.md (Red : Untracked file) + +//that i am want to not push on github main branch so that i make another branch name any that you want you. +// why we make another branch because my Readme file is not professional way +//my readme file is look like Rough or simple tipe + + git checkout -b networking +git add . + +make a file .gitignore for not want to publish on github Repository, or i don't want to push on github repository + +vim .gitignore +.Ds_store + +>exit +git commit -m "added networking solution" +git push origin networking //networking is a subbranch + +//but you can push with this method. + +// you can put token on .gitignore file + +## What SHOULD be in version Control? +1.Unit Tests +2.Build Scripts +3.Source Code +4.Documentation +5.Database Schema +6.Configuration files +7.Deployment Script +8. Kubernetes manifests +9. Docker and compose files +10.Infrastructure as Code (IaC) Files +11.Dependency Lock Files: e.g, package-lock.json + + +## What should Not be in Version Control? +1.Logs +2.Secrets +3.Build Artifacts +4.Large Binary Files +5.IDE or OS-Specific Files +6.Temporary or Cache Files + +//Use Git tags to mark versions so you can navigate back or forth as needed. + +Remember: Version control isn't about tracking code--it's a Blueprint of Entire Application. + +terminal: +man git // for all git command list + +# Branching Strategy #1 +master/main // default Branch +// production branch +production = master +testing = staging branch +Development = Dev Branch +Features = Feat /for new member +Features🔀 >Development✳️ >testing♻️ >production✅️ + +merge another branch for push Best Quality code + +master can create another branch for Error code/ notFix + +notFix can merge with master and staging. +Dev merge by staging, +staging merge by Feature branch + +Jira Tool : +git branch +git fetch /all branch list +git checkout -b git-challenge + +cd 2025 +cd git +vim Readme.md +week 3 challenge on Git +exit +git add Readme.md +git commit -m "TWS-9 added git challenge" +git push origin git-challenge + +on github + +90DaysOfDevOps/2025/git/ +Readme.md: +Week Challenge on Git + +compare pull Request with master and git-challenge + +give title : TWS-9(Jira Ticket Id) added git-challenge + +but not click on merge button + + +#merge means // pull Request in github + +## This is professional way git learn + +git rebase// isme commit history time ke according linear way mentain karti hai +वह rewrite kar deta hai apke commit history ko +//isliye rebase bahut kam use hota hai + + + +git merge// isme commit history ko utal putal kar deta hai + + + + + + diff --git a/Git & Github Advanced/Git & Github Advanced.md b/Git & Github Advanced/Git & Github Advanced.md new file mode 100644 index 0000000..407b8ae --- /dev/null +++ b/Git & Github Advanced/Git & Github Advanced.md @@ -0,0 +1,266 @@ +**Start Here:** + +```markdown +# GitHub Advanced +* Pull Requests = merge Request🔄 +* Revert & Reset🔄 +* Stashing +* Cherry-Picking +* Rebasing +* Branching Strategies used in Companies + +## Theory start Here: +Launch instance: +in Aws Ec2: + + +''git is version control system +founder of linux is create git'' +git merge dev + +pull request ✅️ +Revert & Reset // is just like undo commit or wrong commit +git log --oneline // to see all commit +git revert +git commit -m "some changes on commit" +again give conflict massage change some in file +using vim + +git revert --continue //fix conflict and run command line + +git revert --skip // to skip this patch⚠️ +git revert --abort // to cancel the revert operation⚠️ + + +git reset + +git restore --staged + +git stash & pupping + +git Stashing list + +git stash pop 0 + +git cherry-Pick + +git rebase dev + + + + + + + +## Git & Github CheatSheet + +### Repository management + + +| Command | Description | +| ------------- | ------------- | +| Git init | Intialize a new repository | +| git clone // Link local repo to remote +Adding and community: +git add //stage changes for commit +git add . // stage all changes +git commit -m "message" //commit changes with a message +git commit --amend // edit the last commit + +Branching and Merging: + git branch //List Branches + git branch // create a new branch + git checkout -b // create and switch to a new branch + git merge // Merge a branch into current branch + git branch -d Delete a branch + git Checkout // Switch to a branch + + Log and History: + + git log //view commit history + git log --oneline // view commit history in one line + git diff // view unstaged changes + git diff HEAD //compare working directory to HEAD + +Undo changes: + +git reset unstages a file Changes remain in the working directory +git restore //Restores a file to its last committed state +git reset --hard //Resets the current branch to the specified commit and discords all local changes. +git revert Create a new commit that undoes a previous commit + + +Pushing and pulling : + +git push origin // Push changes to the remote repository +git pull origin // Pull changes from the remote repository + + +Log Git Config command : + +git config --global user.name "" //Sets the global username for git commits. +git config --global user.email "" //Sets the global email for git commits. +git config --list // Display the current Git configuration (User details, editor, etc) + +Git Status command: + +git status // Shows the current status of the working directory and stagging area, indicates tracked, modified , untracked , or staged files + +Git Fetch Command: + +git fetch // downloads commits files and references from a remote repository without merging them into the local branch. + + +# Advanced Commands + +Stashing Command: + +git stash // Save changes to a Stash +git stash list //List all stashes +git stash apply //Apply the lost stash +git stash drop //Delete the last stash + +Rebase and Cherry-Pick: + +git rebase //Reapplies commits on top of another base branch. It rewrite history. so avoid using it on shared branches. + +git rebase -i //Allows you to rebase interactively from a specific commit. + +git rebase --abort // Aborts the rebase process and returns to the state before starting the rebase + +git rebase --continue //continues the rebase after resolving conflicts + +git rebase --skip // Skips the current commit during rebase. + +git cherry-pick Applies a specific commit from another branch to the current branch. + +Tagging: +git tag // Create a lightweight tag + +git tag -a -m "msg" //Create an annotated tag + +git push origin --tags // Push tags to remote + + +Git Bisect Command (Debugging to find Bad commits): + +git bisect start // Begins the binary search to find the commit that introduced a bug. + +git bisect good //marks a known good commit (does not contain the bug) to start the bisecting process + +git bisect reset //Ends the bisect process and resets the repository to the original state. + +collaboration commands: +git blame //Shows who modified each line of the file. +git shortlog // summarizes contributions by author +git log --graph //visualize branch history +git show // Displays details of a specific commit +git diff --staged // Show differnce between staged changes and the last commit + +# GitHub push Methods: +1. SSH Method: +--1.Generate on SSH key: + using: `ssh-keygen` + +--2.Copy the SSH key: + using: `cat ~/.ssh/.pub` + +--3.Navigate to Github > Settings > SSH and GPG keys> New SSH key. + +--4.Paste the key and save. + +--5.Verify the SSH connection: + using: `ssh-T git@github.com` + +--6.Now clone the repo using ssh and do whatever you want and add & commit the changes + +--7.Push code: + using:`git push origin main` + +# 2.HTTPS Method +--1.Firstly Generate a Personal Access Token +--2.Use HTTPS URL for your repository: + `git remote set-url origin https://@github.com//.git` +--3.Add and commit the changes +--4.Push code: + `git push origin main/master` + + # Helpful Github Tips: + + ## Create Pull Request: + 1.Push branch to github. + 2.Open the repository on Github. + 3.Go to the "Pull Requests" tab and click "New Pull Request" + 4.Select branches and create PR. + + GitHub Fork and Sync Workflow : + + 1. Fork a Repository: + a. Go to the repository on github and click on Fork. + + 2. Clone the Fork: + a.`git clone https://github.com/your-username/repo-name.git` + 3. Sync changes from Upstream: + a.git remote add upstream https://github.com/original-owner/repo-name.git + b.git fetch upstream + c.git merge upstream/main + +# Git Aliases : +Speed up your workflow by aliases: +1. git config --global alias.co checkout +2. git config --global alias.br branch +3. git config --global alias.ci commit + +# GitHub Actions: +.Significance: Automates workflows like testing, building and deploying code. +.Example: +```yml Start here: +name: CI/CD Pipeline #Name of the workflow +on: + push: #Triger workflow on push to main branch. + branches: + - main + pull_request: + branches: + - main +jobs: + build: #Define a job name 'build' + runs-on: ubuntu-latest # Use the latest Ubuntu environment +steps: + - name: Checkout Code + uses: actions/checkout@v2 + - name: Install Dependencies + run: npm install + - name: Run Tests + run: npm test + +```Markdown + +# References: + - Git Documentation + - GitHub Docs + + + + + + + + + + + + + + + + + diff --git a/Git & Github Advanced/Realese.md b/Git & Github Advanced/Realese.md new file mode 100644 index 0000000..9862cac --- /dev/null +++ b/Git & Github Advanced/Realese.md @@ -0,0 +1 @@ +This is a Realese File diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..c9f9873 --- /dev/null +++ b/Readme.md @@ -0,0 +1 @@ +# NetworkingInOneShot