{"id":27940774,"url":"https://github.com/cdobratz/git-command-cheat-sheet","last_synced_at":"2026-05-15T22:34:30.686Z","repository":{"id":46490034,"uuid":"409345623","full_name":"cdobratz/Git-Command-Cheat-Sheet","owner":"cdobratz","description":"This repository is to store a reference sheet of git and github commands.","archived":false,"fork":false,"pushed_at":"2024-02-15T17:26:55.000Z","size":402,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-17T09:55:13.568Z","etag":null,"topics":["git","github"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cdobratz.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,"zenodo":null}},"created_at":"2021-09-22T20:23:25.000Z","updated_at":"2024-01-31T21:32:44.000Z","dependencies_parsed_at":"2025-05-07T10:26:47.059Z","dependency_job_id":"9119fd8d-b279-4117-884d-34761eadd1ef","html_url":"https://github.com/cdobratz/Git-Command-Cheat-Sheet","commit_stats":null,"previous_names":["cdobratz/git-command-cheat-sheet"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cdobratz/Git-Command-Cheat-Sheet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdobratz%2FGit-Command-Cheat-Sheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdobratz%2FGit-Command-Cheat-Sheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdobratz%2FGit-Command-Cheat-Sheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdobratz%2FGit-Command-Cheat-Sheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdobratz","download_url":"https://codeload.github.com/cdobratz/Git-Command-Cheat-Sheet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdobratz%2FGit-Command-Cheat-Sheet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33082048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T20:25:35.270Z","status":"ssl_error","status_checked_at":"2026-05-15T20:25:34.732Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["git","github"],"created_at":"2025-05-07T10:21:00.395Z","updated_at":"2026-05-15T22:34:30.670Z","avatar_url":"https://github.com/cdobratz.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# One More Git Cheatsheet \n\n#### This document is study resources to prepare for the Github Foundation Certification.\nOriginally this repo started to house basic git commands. Recently I am adding my notes as I go through [this course](https://www.exampro.co/github-choose-an-exam) from Andrew Brown of ExamPro.\n\n### Table of Contents\n\n\u003c!-- TOC start (generated with https://github.com/derlin/bitdowntoc) --\u003e\n\n- [Git Overview of Terms](#git-overview-of-terms)\n- [Basic Commands ](#basic_commands)\n   * [Create](#create)\n     - [From existing repo](#from-existing-repo)\n     - [From existing files](#from-existing-files)\n   * [Commit](#commit)\n    - [Commit only watches changes that have been marked explictly with add](#commit-only-watches-changes-that-have-been-marked-explictly-with-add)\n   * [View](#view)\n   * [Branches](#branches)\n   * [Update](#update)\n   * [Remote](#remote)\n- [This describes a new commit that undoes previous commits](#this-describes-a-new-commit-that-undoes-previous-commits)\n* [Useful Tools](#useful-tools)\n+ [Git Workflow](#git-workflow)\n\n\u003c!-- TOC end --\u003e\n\n![Octocat!](/images/cd_octocat_med.png \"Octocat Flair!\")\n\n\u003c!-- TOC --\u003e\u003ca name=\"git-overview-of-terms\"\u003e\u003c/a\u003e\n## Git Overview of Terms\n- **Repository** (repo): Represents the container holding the codebase \n- **Commit**: Represents a change of data in the local repo.\n- **Tree**: Represents the entire history of a repo.\n- **Remote**: A version of your project hosted elsewhere, used for exchanging commits.\n- **Branches**: Divergent paths of developement, allowing isolated changes.\n- **Main** (formally known as Master): common name for default branch\n- **Clone**: Creates a complete local copy of a repo, including its history.\n- **Checkout**: Switches between different branches or commits in your repo.\n- **Pull**: Downloads changes from remote repo and merges them into your branch\n- **Push**: Uploads local repo changes to a remote repo.\n- **Fetch**: Downloads data from remote repo without integrating it into your work\n- **Reset**: Undoes local changes, with options to unstage or revert commits.\n- **Merge**: Combines multiple commit histories into one.\n- **Staging** files: Prepares and organizes for a commit.\n    - Add: Adds changes to file or files bringing them to the staging area for the next commit.\n    - Commit: Saves changes as a snapshot in the local repo\n\n- To see the complete documentation follow [Links to Git Docs](https://git-scm.com/docs)\n- If your in the wild and get stuck use `git help` [command]\n\n\u003c!-- TOC --\u003e\u003ca name=\"basic_commands\"\u003e\u003c/a\u003e\n### Basic Commands\n\n```bash\nmain      # default level branch\norigin    # default upstream\nHEAD      # current branch\nHEAD^     # parent of HEAD\n```\n\n\u003c!-- TOC --\u003e\u003ca name=\"create\"\u003e\u003c/a\u003e\n### Create\n\n\u003c!-- TOC --\u003e\u003ca name=\"from-existing-repo\"\u003e\u003c/a\u003e\n##### From existing repo\n\nThree main ways to clone a repo\n- HTTPS\n- SSH\n- Github CLI\n\nIt is possible to clone entire repo or a single branch\n\n```python\ngit clone [URL] #bring repo from existing repo\ngit clone ~/old ~/new\ngit clone --single-branch\n```\n\n\u003c!-- TOC --\u003e\u003ca name=\"from-existing-files\"\u003e\u003c/a\u003e\n##### From existing files\n\n```python\ngit init`\ngit add my file #add file to repo from local to repo\ngit add . #add all files\ngit diff --staged #used after `git add` to review changes to code\n```\n\u003c!-- TOC --\u003e\u003ca name=\"commit\"\u003e\u003c/a\u003e\n### Commit\n\n\u003c!-- TOC --\u003e\u003ca name=\"commit-only-watches-changes-that-have-been-marked-explictly-with-add\"\u003e\u003c/a\u003e\n##### Watches changes that have been marked explictly with add\n\n```python\ngit commit -m \"Commit Message\" # add changes of repo to main branch\ngit commit -a -m \"Com Message\" # -a: automatically stages all tracked modified files before commit\ngit commit --amend # Modifies most recent commit\ngit commit -m \"Initial Commit\" --allow empty # Creates empty commit to act as placeholder\ngit commit -m \"Message\" --author=\"name \u003cemail@example.com\u003e\" # commit with specific author\ngit push # send local files to remote\ngit push -u origin # the -u sets upstream branch\n```\n\n\u003c!-- TOC --\u003e\u003ca name=\"view\"\u003e\u003c/a\u003e\n### View\n\n```python\ngit status # check local files to main github branch\ngit diff [oldid newid]\ngit log [-p] [file|dir]\ngit blame file\ngit show id\ngit show id:file\ngit branch # see branches\n```\n\n\u003c!-- TOC --\u003e\u003ca name=\"branches\"\u003e\u003c/a\u003e\n### Branches\nCan be created through\n- Issues tab\n- w/ GitHub UI\n- w/ GitHub Desktop\n- In terminal (below)\n  \n```python\ngit branch # Lists all local branches\ngit branch [branch-name] # creates new branch\ngit branch -m [old-name][new-name] # Rename a branch\ngit branch -d anybranch # with -d anybranch will be deleted\ngit branch -a # Lists both remote and local branches\ngit checkout [branch-name] # switchs to branch-name\ngit checkout -b newbranch # this creates and moves to new branch\ngit merge # branches together\n```\n\n\u003c!-- TOC --\u003e\u003ca name=\"update\"\u003e\u003c/a\u003e\n### Update\n```python\ngit pull # get latest changes from branch\ngit fetch [remote-name] # Fetch updates withour pulling\ngit apply patch.diff\n```\n\n\u003c!-- TOC --\u003e\u003ca name=\"remote\"\u003e\u003c/a\u003e\n### Remote\n```python\n# Lists all remote repositories along with their URLs\ngit remote -v\ngit remote add [name] [URL]                \ngit remote remove [name]     \ngit remote rename [old-name] [new-name]\n```\n  \n```pythoh\n# Pushes a branch and its commits to the specific remote\ngit push [remote-name] [branch]\n  \n# Pull updates from a remote branch        \ngit pull [remote-name] [branch]\n```          \n\n\n\u003c!-- TOC --\u003e\u003ca name=\"this-describes-a-new-commit-that-undoes-previous-commits\"\u003e\u003c/a\u003e\n##### This describes a new commit that undoes previous commits\n```python\ngit reset --hard # NOT UNDONE, reset to last commit\ngit revert branch\ngit commit -a --amend # replaces prev commit\n```\n\n\u003c!-- TOC --\u003e\u003ca name=\"useful-tools\"\u003e\u003c/a\u003e\n### Useful Tools\n\n- `git log` *view log history*\n- `git archive` *create release tarball*\n- `git bisect` *binary search for defects*\n- `git cherry-pick` *take single commit from elsewhere*\n- `git fsck` *check tree*\n- `git gc` *compress metadata \u003cperformance\u003e*\n- `git rebase` *forward-port local changes to remote branch* \n- `git remote add URL` *register new remote repo for tree*\n- `git stash` *Temporarily set aside changes*\n\n\n\n\u003c!-- TOC --\u003e\u003ca name=\"git-workflow\"\u003e\u003c/a\u003e\n#### Git Workflows\n\n\u003e##### Simple Github Workflow Example\n\u003e\n\u003e - Create new branch\n\u003e - Add new feature and code\n\u003e - add, commit, and push changes to the remote\n\u003e - Get changes reviewed by team member\n\u003e - Delete remote branch\n\u003e - Delete local branch\n\u003e - Pull new code on the remote master to local machine\n\u003e\n\n##### Workflow with commands\n\n```bash\ngit checkout -b my-new-branch\n# ... make changes to files \ngit add .   \ngit commit -m \"my changes\"   \ngit push -u origin my-new-branch \n```\n\n#### Extra modifications\n- After pull request complete\n- `git tag 1.0.1`\n- `git push --tags`\n\n\u003e The rest of the notes can be found at my [other Repo](https://github.com/AVhouse/Certification-Study-Notes)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdobratz%2Fgit-command-cheat-sheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdobratz%2Fgit-command-cheat-sheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdobratz%2Fgit-command-cheat-sheet/lists"}