{"id":25645750,"url":"https://github.com/pawarrachana06/github-notes","last_synced_at":"2026-05-31T16:32:02.394Z","repository":{"id":277374680,"uuid":"932217359","full_name":"pawarrachana06/github-Notes","owner":"pawarrachana06","description":"Git commands ","archived":false,"fork":false,"pushed_at":"2025-08-22T11:45:10.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-22T12:36:30.580Z","etag":null,"topics":["git"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pawarrachana06.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-13T15:04:18.000Z","updated_at":"2025-08-22T11:45:13.000Z","dependencies_parsed_at":"2025-08-22T12:14:49.866Z","dependency_job_id":null,"html_url":"https://github.com/pawarrachana06/github-Notes","commit_stats":null,"previous_names":["pawarrachana06/githutb-commands","pawarrachana06/github-notes"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pawarrachana06/github-Notes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawarrachana06%2Fgithub-Notes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawarrachana06%2Fgithub-Notes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawarrachana06%2Fgithub-Notes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawarrachana06%2Fgithub-Notes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pawarrachana06","download_url":"https://codeload.github.com/pawarrachana06/github-Notes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawarrachana06%2Fgithub-Notes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33739861,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git"],"created_at":"2025-02-23T09:18:59.891Z","updated_at":"2026-05-31T16:32:02.370Z","avatar_url":"https://github.com/pawarrachana06.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"## GIT COMMAND AND DESCRIPTIONS NOTES\n\nGit is free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.\n\n## Advantages\n\n- Tracking Changes\n- Managing project code\n- Working with multiple members\n\n## Setup\n\n- Download Git from [Git](https://git-scm.com/downloads)\n- Create a Github account\n\n## Configurations\n\n- Set the email and username with below commands. Needed for tracking, which commit is by whom. (--global: When you want a default Git configuration across all projects, --local:When you want different Git settings for different projects )\n\n`git config --global/local user.email=\"example@email.com`\n\n` git config --global/local user.name=\"user name\"`\n\n- To check the configurations\n\n` git config list`\n\n## Lifecycle\n![Git Lifecycle](https://miro.medium.com/max/552/1*J1qnVEUXzoDgROobmjjR_Q.png)\n\n[Image source](https://miro.medium.com/max/552/1*J1qnVEUXzoDgROobmjjR_Q.png)\n\n\n## Commands \n- To initialize a new Git repository in a directory.\nA .git directory is created inside your project folder. This directory contains all the metadata required for version control.\n` git init `\n\n- Moves changes from the working directory to the staging area.\nIs used to stage changes in Git, preparing them for a commit. It tells Git to include specific files or changes in the next commit.\n` git add filename`\n\n` git add . `\n- Save Staged Changes to Git History\nRecords staged changes into the repository's history.\n\n` git commit -m \"commit message , one liner for changes done\" `\n\n` git commit --amend  # modify the last commit message`\n\n- Rename the Current Branch to main\nThis command renames the current Git branch to main,-M (move) forces the rename, even if a branch named main already exists.\n` git branch -M main`\n\n- Link Local Repository to Remote\nThis command connects your local Git repository to a remote repository.\n\n` git remote add origin link `\n\n` git remote -v # list the remote links` \n\n` git remote rm origin `\n\n- Push Local Changes to Remote Repository\nThis command uploads your local branch (main) to the remote repository (origin) and sets it as the default upstream branch.\n-u or --set-upstream → Links the local main branch to the remote main branch.\nAfter this, you can simply use git push next time (without specifying origin main).\n\n` git push -u origin branchname`\n\n` git push `\n\n- Check the Current State of Your Repository\nThe git status command shows the current status of your working directory and staging area. It helps you track:\n- Untracked files (new files not yet added to Git)\n- Changes staged for commit\n- Changes not staged for commit\n- The current branch and its relationship with the remote repository\n\n` git status `\n\n- View Commit History\nThe git log command displays a list of commits in your repository, showing useful details such as:\n\n- Commit hash (unique ID)\n- Author\n- Date\n- Commit message\n\n\n- The git log command shows the history of commits in your repository.\n\n` git log `\n\n` git log --oneline # one line history log`\n\n- Take changes from the branch\nUsed to fetch the latest changes from a remote repository and merge them into your current branch.\n\n\n` git pull origin main `\n\n- Unstages a file without deleting changes\n  \nUnstages filename from the staging area (index), but keeps the changes in your working directory.\nIf you added a file to staging (git add), but don’t want it in the next commit\n\n` git restore --staged filename`\n\n- Untracks a file but keeps it locally\nIf you added a file to Git but now want to stop tracking it while keeping it on disk.\n\n` git rm --cached filename `\n\n- Shows changes in files before staging or committing\nTo see what has changed in your working directory before staging\n\n\n` git diff `\n\n- Temporarily saves uncommitted changes\nIf you need to switch branches or pull updates but don’t want to commit yet\n\n\n` git stash `\n\n` git stash pop  # To Get the changes back into working directory`\n\n` git stash list # List all the stash created `\n\n` git stash clear # Delete all the changes saved temporarily `\n\n` git stash save 'tag' # Svae the changes with a specific name`\n\n` git stash apply tag # Remove and apply it to current changes`\n\n## Branches\n\n- Creates a new branch\nTo create a new branch without switching to it\n\n\n` git branch branchname `\n\n\n- To Move to the branch created\n\n` git checkout branchname `\n\n` git switch branchname `\n\n- Merges branchname into the current branch\nTo combine changes from another branch into your current branch\n\n` git merge branchname  # If conflict notifies to resolve`\n\n- Deletes a branch (only if merged)\nRemoves branchname locally but keeps history intact\n\n` git branch -d branchname `\n\n\n` git push origin --delete branchname # Removes branchname from the remote repository.`\n\n- To create and move to branch together\n\n` git checkout -b branchname `\n\n` git switch -c new-branch `\n\n- To List the branches created locally and remotely\n\n` git branch -v # -v local branches -r remote branches `\n\n` git branch list #  Lists all local branches `\n\n\n` git branch --merged  # Lists branches that are already merged`\n\n\n` git branch -D branchname # Force deletes a branch (even if unmerged)`\n\n## Rebase\n\n- Rebasing the Current Branch onto feature\nMoves your current branch on top of the feature branch, making it look like all your changes were made after the latest feature branch updates.\n\n🔹 What Happens During git rebase feature?\n- Git takes all commits from your current branch that are not in feature.\n- It re-applies them on top of the feature branch, one by one.\n- This creates a cleaner history without unnecessary merge commits.\n\n  \n  \n` git rebase branchname `\n\n\nBefore Rebasing (develop is checked out)\n\n\n` mathematica\nA --- B --- C  (feature)\n       \\\n        D --- E --- F  (develop, current branch) `\n        \nAfter Running git rebase feature\n\n\n` mathematica\nA --- B --- C  (feature)\n              \\\n               D' --- E' --- F'  (develop, rebased) `\n\n               \n- Commits D, E, F are rebased onto feature.\n\n- Each commit gets a new hash, as they are reapplied.\n\n-  When Do You Use git rebase --continue?\n  \n✅ You started a git rebase, but there was a merge conflict.\n✅ You fixed the conflict and staged the changes (git add .).\n✅ Now, you need to resume the rebase process.\n\n\n` git rebase --continue `\n\n## Squash\n- Interactive Rebase to Modify Last Commits\nThe interactive rebase (-i) lets you edit, squash, reorder, or delete commits in a safe and controlled way.\n\n\n` git rebase  -i HEAD ~ no.of commits `\n\n\n🔹 How to Use Interactive Rebase\n\n\n1️⃣ Run the command:\n\n`sh\ngit rebase -i HEAD~4 `\n\n\nThis opens an interactive editor with a list of the last 4 commits.\n\n\n2️⃣ Modify the commits (Example Editor Output)\n\n` sql\npick 123abc First commit\npick 456def Second commit\npick 789ghi Third commit\npick 012jkl Fourth commit `\n\n\nEach commit starts with the word pick.\n\nYou can change pick to edit, squash, reword, or drop:\n- Command\tEffect\n- pick\tKeep the commit as is\n- reword\tEdit commit message\n- edit\tModify the commit\n- squash (or s)\tMerge commit into the one before it\n- drop\tDelete commit\n\n\n## Revert \n- Revert a Commit Without Changing History\nThe git revert command creates a new commit that undoes the changes from a previous commit, without modifying commit history.\n\n\n` git revert HEAD ~2 `\n\n## Reset\n- Reset Commits Without Losing Changes\nThis command moves the HEAD (the latest commit pointer) back by index commits, keeping all changes staged.\n\n` git reset --soft HEAD ~ index # starts with 0 `\n\n` git reset --mixed HEAD~1  # Undo commit, keep changes unstaged`\n\n` git reset --hard HEAD ~ index  #Undo commit \u0026 remove changes permanently`\n\n \n ## Difference Between git revert and git reset:\n\n- git reset moves the branch pointer back, altering history (not recommended for shared repos).\n- git revert creates a new commit, safely reversing changes without rewriting history.\n\n## Note Recover Lost Commits \u0026 Track History\n- Whenever you commit, reset, checkout, merge, rebase, or cherry-pick, Git logs these actions.\nEven if a commit is lost due to git reset --hard, you can recover it using git reflog.\n\n\nLists recent HEAD movements with their commit hashes.\n\n` git reflog  `\n\n## Tags \u0026 Release\n\n- Create a Tag in Git \nA Git tag is a way to mark specific points in your commit history, often used for version releases (e.g., v1.0.0).\n  \n` git tag tagname `\n\n` git tag # List the tags  `\n\n` git tag -d v1.0.0 # Delete a local tag `\n\n` git push origin --delete v1.0.0  # Delete a remote tag`\n\n\n- Push a Specific Tag to Remote\nThis command pushes a specific Git tag from your local repository to a remote repository.\n\n` git push origin tagname `\n\n\n## Cherry pick\n- Apply a specific commit from another branch\nBrings in the changes from a specific commit without merging the entire branch\n\n\n``` git cherry-pick commitHash ```\n\n\n\n## Fork\nA fork is a personal copy of someone else's Git repository. It allows you to:\n\n- Experiment with changes without affecting the original repo.\n- Contribute to open-source projects by making changes in your fork and submitting a pull request.\n- Maintain a separate version of a project with your modifications.\n\n## How to Fork a Repository\n\n\n1️⃣ Go to the Repository\n\nVisit the GitHub repository you want to fork.\n\n2️⃣ Click the \"Fork\" Button\n\n\nThis creates a copy of the repository under your GitHub account.\n\n\n3️⃣ Clone the Forked Repository to Your Local Machine\n\n\n`sh\ngit clone https://github.com/your-username/forked-repo.git\ncd forked-repo`\n\n4️⃣ Add the Original Repository as a Remote (upstream)\n\n`sh\ngit remote add upstream https://github.com/original-owner/original-repo.git`\n- origin refers to your fork.\n- upstream refers to the original repo.\nKeeping Your Fork Updated\n\n1️⃣ Fetch Changes from the Original Repo\n\n\n`sh\ngit fetch upstream`\n\n2️⃣ Merge Changes into Your Fork\n\n`sh\ngit checkout main\ngit merge upstream/main`\n\n3️⃣ Push the Updates to Your GitHub Fork\n`\nsh\ngit push origin main`\n\n\n## How to avoid some file from being tracked by VC\nA .gitignore file tells Git which files and directories to ignore (i.e., not track or commit). This is useful for:\n- Temporary files (logs, caches)\n- Environment-specific files (config, secrets)\n- Dependency folders (e.g., node_modules/)\n- Compiled files (e.g., .class, .o, .exe)\n\nCreate a file named .gitignore in the current directory.\n.gitignore file .[Refer these repo for writing .gitignore files for different Framework/Programming Language](https://github.com/github/gitignore) \n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpawarrachana06%2Fgithub-notes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpawarrachana06%2Fgithub-notes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpawarrachana06%2Fgithub-notes/lists"}