{"id":16464802,"url":"https://github.com/shakilgithub20/git-commands-guide","last_synced_at":"2026-03-18T19:50:19.380Z","repository":{"id":50728604,"uuid":"379171992","full_name":"Shakilgithub20/Git-Commands-Guide","owner":"Shakilgithub20","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-08T18:12:19.000Z","size":107,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-30T11:59:52.784Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Shakilgithub20.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}},"created_at":"2021-06-22T06:55:44.000Z","updated_at":"2024-07-19T18:53:39.000Z","dependencies_parsed_at":"2024-11-11T20:40:44.823Z","dependency_job_id":"e91c0dfc-eaf8-4b23-b09c-b2b2f032546b","html_url":"https://github.com/Shakilgithub20/Git-Commands-Guide","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Shakilgithub20/Git-Commands-Guide","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shakilgithub20%2FGit-Commands-Guide","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shakilgithub20%2FGit-Commands-Guide/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shakilgithub20%2FGit-Commands-Guide/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shakilgithub20%2FGit-Commands-Guide/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shakilgithub20","download_url":"https://codeload.github.com/Shakilgithub20/Git-Commands-Guide/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shakilgithub20%2FGit-Commands-Guide/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29270917,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T13:47:44.167Z","status":"ssl_error","status_checked_at":"2026-02-09T13:47:43.721Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-10-11T11:29:55.548Z","updated_at":"2026-02-09T15:33:25.137Z","avatar_url":"https://github.com/Shakilgithub20.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n A-Z Roadmap\n\u003c/h1\u003e\n## Git-Hub:\nGit is the free and open source distributed version control system that's responsible for everything GitHub\nrelated that happens locally on your computer. This cheat sheet features the most important and commonly\nused Git commands for easy reference.\n\n\n## Advantages:\n  - ✔️ Better teamwork\n  - ✔️ Control of changes in the project\n  - ✔️ Audit and reliability\n  - ✔️ Return to previous versions\n  - ✔️ Local \u0026 Remotes Repositories\n  - ▪️▪️▪️ And much more\n\n\n### INSTALLATION \u0026 GUIS:\nWith platform specific installers for Git, GitHub also provides the\nease of staying up-to-date with the latest releases of the command\nline tool while providing a graphical user interface for day-to-day\ninteraction, review, and repository synchronization.\n### GitHub for Windows:\n```\nhtps://windows.github.com\n```\n### GitHub for Mac:\n```\nhtps://mac.github.com\n```\nFor Linux and Solaris platforms, the latest release is available on\nthe official Git web site.\n### Git for All Platforms:\n```\nhtp://git-scm.com\n```\n## Commands 🚀\n___\n\n### GIT Version: 🕵\n\n```\ngit --version\n```\n\n### Configure tooling 🌍 :\n\nConfiguring user information used across all local repositories\n\n```\ngit config --global user.name “[firstname lastname]”\n```\nset a name that is identifiable for credit when review version history\n```\ngit config --global user.email “[valid-email]”\n```\nset an email address that will be associated with each history marker\n```\ngit config --global color.ui auto\n```\nset automatic command line coloring for Git for easy reviewing\n\n\n\n### Configure \u0026 INIT :\nConfiguring user information, initializing and cloning repositories\n```\ngit init\n```\ninitialize an existing directory as a Git repository\n```\ngit clone [url]\n```\nretrieve an entire repository from a hosted location via URL\n\n### Create a Repository 👊\n``` \n# navigated into your folder you want to put on Github\n$ touch README.md # create a file called README.md where you can put instructions/info about your folder like what you are reading right now!\n$ git init # initialize your git repository locally\n$ git add . # adds everything changed from local to staging\n$ git commit -m \"first commit\" # commits everything in staging to be ready to be pushed to Github\n$ git remote add origin https://github.com/.....\n$ git push -u origin master # the \"-u\" is so that the next time your push you don't need to type \"origin master\"\n# put in username \u0026 password\n```\n\n### When adding on to your repository online with changes\n``` \n$ git add .\n$ git add -u # when you have deleted a local file you want to remove from your repository\n$ git commit -m 'what has changed'\n$ git push \n# put in username \u0026 password \n```\n\n### No more username \u0026 password input for every push\n```    \n# Note that you must first generate a SSH key on your local computer and add it to your \n# Github account before using the following command. Follow the directions here:\n# https://help.github.com/articles/generating-ssh-keys\n$ git remote set-url origin git@github.com:yourUsername/yourReponame.git\n```\n### Working together from perspective of person that doesn't have the main repo\n``` \n# fork repo you want to work on\n$ git clone https://github.com/yourUsername/yourReponame.git\n# add changes to your forked repo \n# make a pull request!\n$ git pull # use this after someone else has made a change to the online repo \n           # your working on and you want to make your local repo up to date\n```\n\n### Want to remove a file frome online github repo but keep it locally\n``` \n$ git rm --cached localFileName\n# add localFileName to .gitignore file \n# then commit these changes\n# push these changes to your repo!\n```\n\n### Commands for fixing problems\n``` \n# undo multiple commits  \n$ git reset --hard commitSHA###... # changes staging index and \n                                   # local folder to match online \n                                   # repository commit\n\n# removing 3 commits from online github repo\n$ git push -f origin HEAD^^^:branchNameToUndoLast3Pushs\n```\n### Help Command 🙏\n\n```\ngit help  \n```\n\n### Get help from a specific command 👏\n\n\u003cpre\u003e\ngit help \u003cb\u003ecommit\u003c/b\u003e\n\u003c/pre\u003e\n\n\n### Branches\n| Command | Description |\n| - | - |\n| `git branch foo`                          | Create a new branch |\n| `git switch foo`                          | Switch to a branch |\n| `git switch -c\\|--create foo`             | Create and switch to a branch |\n| `git restore foo.js`                      | Undo all changes on the foo.js file |\n| `git checkout foo.js`                     | Undo all changes on the foo.js file |\n| `git checkout foo`                        | Use `git switch` instead |\n| `git checkout -b foo`                     | Use `git switch -c` instead |\n| `git merge foo`                           | Merge branch into current branch |\n\n\n### Delete \n| Command | Description |\n| - | - |\n| `git branch -d \u003cbranchname\u003e `                       | Delete the local branch, show a warning|\n| `git branch -D \u003cbranhcname\u003e `                       | Force to delete branch|\n| `git remote prune origin `                          | Cleanup remote deleted branch |\n\n\n\n### Pulling\n| Command | Description |\n| - | - |\n| `git pull --rebase --prune`               | Get latest, rebase any changes not checked in and delete branches that no longer exist | \n\n### Staged Changes\n| Command | Description |\n| - | - |\n| `git add file.txt`                        | Stage file |\n| `git add -p`|--patch file.txt`            | Stage some but not all changes in a file |\n| `git mv file1.txt file2.txt`              | Move/rename file |\n| `git rm --cached file.txt`                | Unstage file |\n| `git rm --force file.txt`                 | Unstage and delete file |\n| `git reset HEAD`                          | Unstage changes |\n| `git reset --hard HEAD`                   | Unstage and delete changes |\n| `git clean -f\\|--force -d`                | Recursively remove untracked files from the working tree |\n| `git clean -f\\|--force -d -x`             | Recursively remove untracked and ignored files from the working tree |\n\n### Changing Commits\n| Command | Description |\n| - | - |\n| `git reset 5720fdf`                           | Reset current branch but not working area to commit |\n| `git reset HEAD~1`                            | Reset the current branch but not working area to the previous commit |\n| `git reset --hard 5720fdf`                    | Reset current branch and working area to commit |\n| `git commit --amend -m \"New message\"`         | Change the last commit message |\n| `git commit --fixup 5720fdf -m \"New message\"` | Merge into the specified commit |\n| `git revert 5720fdf`                          | Revert a commit |\n| `git rebase --interactive [origin/main]`      | Rebase a PR (`git pull` first) |\n| `git rebase --interactive 5720fdf`            | Rebase to a particular commit |\n| `git rebase --interactive --root 5720fdf`     | Rebase to the root commit |\n| `git rebase --continue`                       | Continue an interactive rebase |\n| `git rebase --abort`                          | Cancel an interactive rebase |\n| `git cherry-pick 5720fdf`                     | Copy the commit to the current branch |\n\n### Compare\n| Command | Description |\n| - | - |\n| `git diff`                                | See difference between working area and current branch |\n| `git diff HEAD HEAD~2`                    | See difference between te current commit and two previous commits |\n| `git diff main other`                     | See difference between two branches |\n\n### View\n| Command | Description |\n| - | - |\n| `git log`                                 | See commit list |\n| `git log --patch`                         | See commit list and line changes |\n| `git log --decorate --graph --oneline`    | See commit visualization |\n| `git log --grep foo`                      | See commits with foo in the message |\n| `git show HEAD`                           | Show the current commit |\n| `git show HEAD^` or `git show HEAD~1`     | Show the previous commit |\n| `git show HEAD^^` or `git show HEAD~2`    | Show the commit going back two commits |\n| `git show main`                           | Show the last commit in a branch |\n| `git show 5720fdf`                        | Show named commit |\n| `git blame file.txt`                      | See who changed each line and when |\n\n### Stash\n| Command | Description |\n| - | - |\n| `git stash push -m \"Message\"`             | Stash staged files |\n| `git stash --include-untracked`           | Stash working area and staged files |\n| `git stash --staged`                      | Stash staged files |\n| `git stash list`                          | List stashes |\n| `git stash apply`                         | Moved last stash to working area |\n| `git stash apply 0`                       | Moved named stash to working area |\n| `git stash clear`                         | Clear the stash |\n\n### Tags\n| Command | Description |\n| - | - |\n| `git tag`                                              | List all tags |\n| `git tag -a\\|--annotate 0.0.1 -m\\|--message \"Message\"` | Create a tag |\n| `git tag -d\\|--delete 0.0.1`                           | Delete a tag |\n| `git push --tags`                                      | Push tags to remote repository |\n\n### Remote\n| Command | Description |\n| - | - |\n| `git remote -v`                           | List remote repositories |\n| `git remote show origin`                  | Show remote repository details |\n| `git remote add upstream \u003curl\u003e`           | Add remote upstream repository |\n| `git fetch upstream`                      | Fetch all remote branches |\n| `git rebase upstream/main`                | Refresh main branch from upstream |\n| `git remote -v`                           | List remote repositories |\n| `git push --force`                        | Push any changes while overwriting any remote changes |\n| `git push --force-with-lease`             | Push any changes but stop if there are any remote changes |\n| `git push --tags`                         | Push tags to remote repository |\n\n### Submodules\n| Command | Description |\n| - | - |\n| `git submodule status`                    | Check status of all submodules |\n\n- Pull submodules\n  1. `git submodule sync`\n  2. `git submodule init`\n  3. `git submodule update`\n- Change branch\n  1. `cd /submodule`\n  2. `git fetch origin \u003cbranch-name\u003e`\n  3. `git checkout \u003cbranch-name\u003e`\n  4. `cd /`\n \n### Commit:\n\nAdd \u0026 commit\n ```\ngit commit -am 'commit message'   \n```\nCommit empty change\n```\ngit commit --allow-empty -m k3;\n```\nTake a commit change of another branch \n```\ngit cherry-pick \u003ccommit-hash\u003e  \n```\n Add any file\n ```\n git add task2.txt \n ```\n Merge current change to previous commit and will also change the commit hash\n ```\n git commit --amend -m 'new message'\n ```\n ### Merge\n Merge remote 'branch-1' with current branch\n ```\n git merge origin \u003cbranch-1\u003e   \n ```\n ```\n git mergetool\n ```\n ```\n git merge --squash \u003cprivateFeatureBranch\u003e\n ```\n\n### IGNORING PATTERNS\nPreventing unintentional staging or commiting of files\n ```\nlogs/\n*.notes\npattern*/\n ```\nSave a file with desired paterns as .gitignore with either direct string\nmatches or wildcard globs.\n```\ngit config --global core.excludesfile [file]\n```\nsystem wide ignore patern for all local repositories\n\n### REWRITE HISTORY\nRewriting branches, updating commits and clearing history\n```\ngit rebase [branch]\n```\napply any commits of current branch ahead of specified one\n ```\ngit reset --hard [commit]\n ```\nclear staging area, rewrite working tree from specified commit\n \n### TEMPORARY COMMITS\nTemporarily store modified, tracked files in order to change branches\n  ```\ngit stash\n  ```\nSave modified and staged changes\n  ```\ngit stash list\n  ```\nlist stack-order of stashed file changes\n  ```\ngit stash pop\n  ```\nwrite working from top of stash stack\n  ```\ngit stash drop\n  ```\ndiscard the changes from top of stash stack\n \n### SHARE \u0026 UPDATE\nRetrieving updates from another repository and updating local repos\n ```\ngit remote add [alias] [url]\n ```\nadd a git URL as an alias\n ```\ngit fetch [alias]\n ```\nfetch down all the branches from that Git remote\n ```\ngit merge [alias]/[branch]\n ```\nmerge a remote branch into your current branch to bring it up to date\n ```\ngit push [alias] [branch]\n ```\nTransmit local branch commits to the remote repository branch\n ```\ngit pull\n ```\n\n### TRACKING PATH CHANGES\nVersioning file removes and path changes\n  ```\ngit rm [file]\n  ```\ndelete the file from project and stage the removal for commit\n  ```\ngit mv [existing-path] [new-path]\n  ```\nchange an existing file path and stage the move\n  ```\ngit log --stat -M\n  ```\nshow all commit logs with indication of any paths that moved\nfetch and merge any commits from the tracking remote branch\n\n### STAGE \u0026 SNAPSHOT\nWorking with snapshots and the Git staging area\n ```\ngit status\n ```\nshow modified files in working directory, staged for your next commit\n ```\ngit add [file]\n ```\nadd a file as it looks now to your next commit (stage)\n ```\ngit reset [file]\n ```\nunstage a file while retaining the changes in working directory\n ```\ngit diff\n ```\ndiff of what is changed but not staged\n ```\ngit diff --staged\n ```\ndiff of what is staged but not yet commited\n ```\ngit commit -m “[descriptive message]”\n ```\ncommit your staged content as a new commit snapshot\n\n\n### Some more good resources to Learn Git faster ☺️\nGithub:\n ```\nbit.ly/shakil0090\n ```\nGit Official Documentation:\n ```\ngit-scm.com/doc\n ```\nGitHub Learning Lab:\n ```\nhttps://lnkd.in/dfQY6Jtp\n ```\nCodecademy Course\n ```\nhttps://lnkd.in/dwG5_C6q\n ```\nPro Git: by Scott Chacon [Book]\n ```\ngit-scm.com/book/en/v2\n ```\nYouTube\n ```\nFreeCodeCampOrg- beginer : rb.gy/ljxt5s\n ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshakilgithub20%2Fgit-commands-guide","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshakilgithub20%2Fgit-commands-guide","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshakilgithub20%2Fgit-commands-guide/lists"}