{"id":20580042,"url":"https://github.com/iyashwantsaini/git_help","last_synced_at":"2026-04-25T03:05:25.141Z","repository":{"id":112237473,"uuid":"288465637","full_name":"iyashwantsaini/GIT_help","owner":"iyashwantsaini","description":"Contains all basic commands and usage.","archived":false,"fork":false,"pushed_at":"2022-07-13T08:56:24.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-16T22:29:41.182Z","etag":null,"topics":["git","github","version-control"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iyashwantsaini.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2020-08-18T13:35:59.000Z","updated_at":"2022-07-13T08:56:27.000Z","dependencies_parsed_at":"2023-05-11T21:30:37.239Z","dependency_job_id":null,"html_url":"https://github.com/iyashwantsaini/GIT_help","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyashwantsaini%2FGIT_help","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyashwantsaini%2FGIT_help/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyashwantsaini%2FGIT_help/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iyashwantsaini%2FGIT_help/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iyashwantsaini","download_url":"https://codeload.github.com/iyashwantsaini/GIT_help/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242206006,"owners_count":20089252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","github","version-control"],"created_at":"2024-11-16T06:19:52.098Z","updated_at":"2026-04-25T03:05:20.120Z","avatar_url":"https://github.com/iyashwantsaini.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cbr\u003e\n  \u003ca href=\"\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/iyashwantsaini/GIT_help/master/git.png\" alt=\"logo\" width=\"400\"\u003e\u003c/a\u003e\n  \u003cbr\u003e\n    GIT - Version Control System\n  \u003cbr\u003e\n\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003eAll basic GIT commands and usage!\u003c/h4\u003e\n\n## git config\n\n- git config --global user.name \"FIRST_NAME LAST_NAME\"\n- git config --global user.email \"MY_NAME@example.com\"\n\n## git init\n\n- To initialize a repository with git.\n\n```\n\u003e git init\n```\n\n## git status\n\n- to get info on untracked files.\n\n```\n\u003e git status\n\nOn branch master\nYour branch is up to date with 'origin/master'.\nUntracked files:\n  (use \"git add \u003cfile\u003e...\" to include in what will be committed)\n        README.md\n        index.html\n```\n\n## git add\n\n- to add sigle file to tracking logic.\n\n```\n\u003e git add _filename\n```\n\n- to add all files to tracking logic.\n\n```\n\u003e git add .\n\n\u003e git status\n\nOn branch master\nYour branch is up to date with 'origin/master'.\n\nChanges to be committed:\n  (use \"git restore --staged \u003cfile\u003e...\" to unstage)\n        new file:   README.md\n        new file:   index.html\n```\n\n## git commit\n\n- to add currently tracked files to version of the code that we wanna save.\n- \"-m\" : to give our commit a name\n\n```\n\u003e git commit -m \"commit_short_name\"\n\n[master 1598d06] commit_short_name\n 1 file changed, 4 insertions(+)\n```\n\n## git log\n\n- to get info on previous commits\n- last commit is the HEAD in our branch\n- press UP/DOWN to see all.\n- press \"q\" to quit.\n\n```\n\u003e git log\n\ncommit 1598d06b5bfaf85f79281e3bc063c0ba5e3e0917 (HEAD -\u003e master)\nAuthor: meyash \u003cmail@gmail.com\u003e\nDate:   Tue Aug 18 19:21:13 2020 +0530\n\n    four_added\n\ncommit 8ac3233f402d1cd5f0bd58a0546245428ccfd3e8 (origin/master, origin/HEAD)\nAuthor: Yashwant \u003cmail@gmail.com\u003e\nDate:   Tue Aug 18 19:06:00 2020 +0530\n\n    Initial commit\n```\n\n## git checkout\n\n- to go to a previous version of our code.\n- get \"\\_commit_id\" from \"git log\"\n\n```\n\u003e git checkout _commit_id\n\n\u003e git checkout 1598d06b5bfaf85f79281e3bc063c0ba5e3e0917\nNote: switching to '1598d06b5bfaf85f79281e3bc063c0ba5e3e0917'.\n\nYou are in 'detached HEAD' state. You can look around, make experimental\nchanges and commit them, and you can discard any commits you make in this\nstate without impacting any branches by switching back to a branch.\n\nIf you want to create a new branch to retain commits you create, you may\ndo so (now or later) by using -c with the switch command. Example:\n\n  git switch -c \u003cnew-branch-name\u003e\n\nOr undo this operation with:\n\n  git switch -\n\nTurn off this advice by setting config variable advice.detachedHead to false\n\nHEAD is now at 1598d06 four_added\n```\n\n- to get back to lastest version.\n\n```\n\u003e git checkout master\n\nPrevious HEAD position was 1598d06 four_added\nSwitched to branch 'master'\nYour branch is ahead of 'origin/master' by 1 commit.\n  (use \"git push\" to publish your local commits)\n```\n\n- revert/delete all unstaged changes.\n\n```\n\u003e git checkout -- .\n```\n\n## git reset\n\n- to delete previous commit(s).\n- get the ID of the commit just before the commit you wanna delete.\n- all the commits after that commit will be deleted.\n\n```\n\u003e git log\n\ncommit 840ac517754709a6505ba5358b90c2c186adfe26 (HEAD -\u003e master, origin/master, origin/HEAD)\nAuthor: meyash \u003cyashsn2127@gmail.com\u003e\nDate:   Tue Aug 18 20:28:28 2020 +0530\n\n    ten_added\n\ncommit 2e316e281b8419e7d3857f261a83fd3782f3f743\nAuthor: meyash \u003cyashsn2127@gmail.com\u003e\nDate:   Tue Aug 18 19:43:06 2020 +0530\n\n    nine_added\n\ncommit 30fc8d60617f67d23d9e15f4c7ceb7818875978f\nAuthor: meyash \u003cyashsn2127@gmail.com\u003e\nDate:   Tue Aug 18 19:36:58 2020 +0530\n\n    eight_added\n\n\u003e git reset --head _commit_id (of the commit just before the commit you wanna delete)\n\u003e git reset --head 2e316e281b8419e7d3857f261a83fd3782f3f743 (nine_added)\n\n\u003e git log (now nine_added will be the head)\n\ncommit 2e316e281b8419e7d3857f261a83fd3782f3f743 (HEAD -\u003e master, origin/master, origin/HEAD)\nAuthor: meyash \u003cyashsn2127@gmail.com\u003e\nDate:   Tue Aug 18 19:43:06 2020 +0530\n\n    nine_added\n\ncommit 30fc8d60617f67d23d9e15f4c7ceb7818875978f\nAuthor: meyash \u003cyashsn2127@gmail.com\u003e\nDate:   Tue Aug 18 19:36:58 2020 +0530\n\n```\n\n## git branch\n\n- to get name of current working branch\n\n```\n\u003e git branch\n\n* master\n```\n\n- adding a new branch\n- any commits to new branch stays in that branch only.\n\n```\n\u003e git checkout -b branch_name\n\n\u003e git branch\n\n* branch_name\n  master\n```\n\n- merging two branches (after commiting in new branch)\n\n```\n\u003e git checkout master\n\nSwitched to branch 'master'\nYour branch is up to date with 'origin/master'.\n\n\u003e git merge branch_name\n\nUpdating f4d8e6d..faa43be\nFast-forward\n README.md                                          | 49 +++++++++++++++++-----\n et --hard 2e316e281b8419e7d3857f261a83fd3782f3f743 | 41 ------------------\n 2 files changed, 38 insertions(+), 52 deletions(-)\n delete mode 100644 et --hard 2e316e281b8419e7d3857f261a83fd3782f3f743\n\n\u003e git log\n\ncommit faa43be813b477570101afc677d82538b954a0b5 (HEAD -\u003e master, branch_name)\nAuthor: meyash \u003cyashsn2127@gmail.com\u003e\nDate:   Tue Aug 18 21:00:33 2020 +0530\n\n    12_added\n\n12_added is now head of both master and branch_name.\n```\n\n- deleting the new branch (like after merging)\n\n```\n\u003e git branch -D branch_name\n```\n\n- Merging when two branches have different changes at same place.\n- This is called a conflict.\n- You can keep current commit, keep incoming (from the other branch), or keep both.\n\n```\nResolve and commit again in the current branch.\n```\n\n## git remote\n\n- to establish a connection between our local and remote repository.\n\n```\n\u003e git remote add origin https://github.com/meyash/GIT_help.git\n\n\u003e git remote\n\norigin\n\n\u003e git remote -v\n\norigin  https://github.com/meyash/GIT_help.git (fetch)\norigin  https://github.com/meyash/GIT_help.git (push)\n```\n\n- to remove remote repo\n\n```\n\u003e git remote rm origin\n```\n\n## git push\n\n- to upload code from our local to remote repository.\n- \"U\" establishes an upstream for our connectoin.\n\n```\ngit push -U origin master\n```\n\n## git pull\n\n- to get changes made in the remote repo.\n\n```\n\u003e git fetch\n\u003e git checkout master\n\u003e git merge origin/master\n\nOR (all steps in one)\n\n\u003e git pull\n\n```\n\n## git stash\n\n- to save your current code as draft and jump to last commit.\n- use stash in this case instead of using commit.\n\n```\n\u003e git stash\n\nSaved working directory and index state WIP on master: cc696f3 18_added\n```\n\n- to apply last draft to current branch\n\n```\n\u003e git stash apply\n```\n\n- to view all drafts\n\n```\n\u003e git stash list\n\nstash@{0}: WIP on master: cc696f3 18_added\n```\n\n- to apply a particular draft to our current branch.\n\n```\n\u003e git stash apply 0 (index of the stash we wanna apply)\n```\n\n- to save a description with the stash (for easy navigation)\n\n```\n\u003e git stash push -m \"_description_here\"\n```\n\n- to delete a stash\n\n```\n\u003e git stash drop 2 (index of stash you wanna remove)\n```\n\n- to apply stash to current branch and delete it from stash list\n\n```\n\u003e git stash pop 2 (index)\n```\n\n- delete all stashes\n\n```\n\u003e git stash clear\n```\n\n## git merge\n\n- Suppose we have 2 branches \"one\" and \"two\"\n- \"one\" has commits o1,o2\n- \"two\" has commits t1,t2,t3\n- we wanna merge t3 with o2\n- such that \"one\" now has o1,o2,t3(having t2,t1 merged within) commits\n\n```\n\u003e git checkout one\n\u003e git merge two (but this will merge all commits of \"two\" in \"one\")\n```\n\n- so we'll use squash here.\n\n## git squash\n\n- to merge all the commits of the current branch in 1 last commit.\n\n```\n\u003e git merge --squash _branch_name \n\u003e git commit -m \"all_merged\" (this commit will have all the previous commits merged)\n```\n\n## git rebase\n\n- Suppose we have 2 branches \"one\" and \"two\"\n- \"one\" has commits o1,o2,o3,o4\n- \"two\" has commits t1,t2,t3\n- we wanna get o4 as the base of two\n- such that \"two\" now has o4,t1,t2,t3 commits\n\n```\n\u003e git checkout two\n\u003e git rebase master\n\u003e git log (to check)\n```\n\n## License\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE)\n\nBy [Yashwant](https://github.com/iyashwantsaini)\n\n## Contributors\n\n\u003cimg src=\"https://avatars3.githubusercontent.com/u/21121279?s=460\u0026u=f0450278b2b569c4443ab8ee03f9dff7015da5bf\u0026v=4\" width=\"100px;\" alt=\"toofff\"/\u003e\u003cbr /\u003e\n\n\u003ca href=\"https://meyash.xyz/\" style=\"margin-right:30px;\"\u003e\u003cimg src=\"https://meyash.xyz/assets/icons/siteicon.png\" width=\"25\"\u003e\u003c/a\u003e\n\u003ca href=\"https://meyash.xyz/resume.pdf\" style=\"margin-right:30px;\"\u003e\u003cimg src=\"https://cdn.jsdelivr.net/npm/simple-icons@v3/icons/libreoffice.svg\" width=\"25\"\u003e\u003c/a\u003e \n\u003ca href=\"https://www.linkedin.com/in/iyashwantsaini/\" style=\"margin-right:30px;\"\u003e\u003cimg src=\"https://cdn.jsdelivr.net/npm/simple-icons@v3/icons/linkedin.svg\" width=\"25\"\u003e\u003c/a\u003e\n\u003ca href=\"https://twitter.com/iyashwantsaini\" style=\"margin-right:30px;\"\u003e\u003cimg src=\"https://cdn.jsdelivr.net/npm/simple-icons@v3/icons/twitter.svg\" width=\"25\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.instagram.com/iyashwantsaini/\" style=\"margin-right:30px;\"\u003e\u003cimg src=\"https://cdn.jsdelivr.net/npm/simple-icons@v3/icons/instagram.svg\" width=\"25\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiyashwantsaini%2Fgit_help","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiyashwantsaini%2Fgit_help","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiyashwantsaini%2Fgit_help/lists"}