{"id":15697194,"url":"https://github.com/joseluisq/git-cheat-sheet","last_synced_at":"2026-02-13T03:52:14.144Z","repository":{"id":146282649,"uuid":"179294566","full_name":"joseluisq/git-cheat-sheet","owner":"joseluisq","description":"Another Git cheat sheet yet :octocat:","archived":false,"fork":false,"pushed_at":"2019-04-08T10:02:02.000Z","size":11,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-15T18:48:05.187Z","etag":null,"topics":["git","git-cheatsheet"],"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/joseluisq.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}},"created_at":"2019-04-03T13:20:46.000Z","updated_at":"2025-04-21T05:22:26.000Z","dependencies_parsed_at":"2023-10-15T23:24:56.105Z","dependency_job_id":null,"html_url":"https://github.com/joseluisq/git-cheat-sheet","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"319d1278c5f81231d9c0bf8dd93c5ab87a2b90f9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/joseluisq/git-cheat-sheet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseluisq%2Fgit-cheat-sheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseluisq%2Fgit-cheat-sheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseluisq%2Fgit-cheat-sheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseluisq%2Fgit-cheat-sheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joseluisq","download_url":"https://codeload.github.com/joseluisq/git-cheat-sheet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joseluisq%2Fgit-cheat-sheet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274632983,"owners_count":25321312,"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","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"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","git-cheatsheet"],"created_at":"2024-10-03T19:13:45.536Z","updated_at":"2026-02-13T03:52:09.125Z","avatar_url":"https://github.com/joseluisq.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git cheat sheet\n\n\u003e Another Git cheat sheet yet :octocat:\n\n## Menu\n- [Configuration](#commiting)\n- [Commiting](#commiting)\n- [Branching](#branching)\n- [Pulling](#pulling)\n- [Pushing](#pushing)\n- [Logging](#logging)\n- [Tagging](#tagging)\n- [Reflog](#reflog)\n- [Resolve conflicts](#resolve-conflicts)\n- [Aliases](#aliases)\n- [Bonus](#bonus)\n- [Resources](#resources)\n\n## Configuration\n\n#### User setup\n\n```sh\ngit config user.name \"Name\"\ngit config user.email '\u003cname@email.com\u003e'\n```\n\n_**Tip**: Add --global flag for global config._\n\n#### Sign commits using a GPG key\n\nList your gpg keys:\n\n```sh\ngpg --list-secret-keys --keyid-format LONG\n/Users/username/.gnupg/secring.gpg\n  ------------------------------------\nsec   4096R/2AA5B24170567CE0 2019-01-01 [expires: 2020-01-01]\n```\n\n__Tip:__ For a GPG key setup check out [Generating a new GPG key](https://help.github.com/en/articles/generating-a-new-gpg-key)\n\nAdd your GPG signing key in Git globally:\n\n```sh\ngit config --global user.signingkey 2AA5B24170567CE0\n```\n\n__Tip:__ For disable signing commits temporarily try: `git config --global commit.gpgsign false`\n\n#### Global .gitignore file\n\n```sh\ngit config --global core.excludesfile ~/.gitignore\n```\n\n#### Add remote origin\n\n```sh\ngit remote add \u003cremote_origin\u003e \u003crepo_url\u003e\n```\n\n#### Remove remote origin\n\n```sh\ngit remote remove \u003cremote_origin\u003e\n```\n\n## Commiting\n\n#### Show the working tree status\n\n```sh\ngit status\n```\n\n_**Tip**: Use `-sb` flag to see the status in a compact way._\n\n#### Stage files to commit\n\n```sh\ngit add \u003csome_files_or_directories\u003e\n```\n\n_**Tips**: Use a dot `git add .` to stage all files for commit._\n\n#### Commit a change\n\n```sh\ngit commit \u003csome_files_or_directories\u003e\n```\n\n_**Tips**: Add `-m \"Message here\"` to commit with a message directly._\n\n#### Change last commit message\n\n```sh\ngit commit --amend\n```\n\n_**Tip**: Add `--author=\"Name \u003cname@email\u003e\"` to override author._\n\n#### Revert previous commit but keeping last changes\n\n```sh\ngit reset HEAD^\n```\n\n#### Revert previous commit (no safety)\n\n_**Caution**: This command throws away all your uncommitted changes. For safety, you should always check that the output of `git status` is clean (that is, empty) before using it. [See this thread for more details](https://stackoverflow.com/a/9530204/2510591)._\n\n```sh\ngit reset --hard HEAD\n```\n\n#### Cherry-pick a commit\n\n[Cherry pick](https://git-scm.com/docs/git-cherry-pick) means to choose a commit from one branch and apply it onto another. [See this thread for more details](https://stackoverflow.com/a/9339460/2510591).\n\n```sh\ngit cherry-pick \u003cother_branch_parent_commit\u003e -m 1\n```\n\n**Note**: Parent number starting from 1. [See this thread for more details](https://stackoverflow.com/a/9339460/2510591).\n\n#### Cherry-pick last commit\n\n```sh\ngit cherry-pick $(git rev-parse \u003cother_branch_name\u003e) -m 1\n```\n\n## Branching\n\n#### Create a new branch and start it\n\n```sh\ngit checkout -b \u003cnew_branch\u003e\n```\n\n#### Checkout a remote branch\n\n```sh\ngit checkout -tb \u003clocal_branch\u003e origin/\u003cremote_branch\u003e\n```\n\n#### Rename a branch\n\n```sh\ngit branch -m \u003cnew_branch_name\u003e\n```\n\n_**Tip**: Use `-M` flag to forcing instead._\n\n#### List all branches\n\n```sh\ngit branch -a\n```\n\n#### List remote branches\n\n```sh\ngit branch -r\n```\n\n#### Delete branches\n\n```sh\ngit branch -d \u003cbranch_name_1\u003e \u003cbranch_name_2\u003e \u003cbranch_name_n\u003e\n```\n\n_**Tip**: Tip: Use `-D` flag to forcing instead._\n\n#### Merge two branches\n\n```sh\ngit checkout \u003ctarget_branch\u003e\ngit merge \u003csource_branch\u003e\n```\n\n_**Tip**: Add `--squash` flat for a squash merging._\n\n## Pulling\n\n#### Pull changes from remote server but saving uncommitted changes\n\nThis command makes this for you:\n\n- Save your uncommitted changes locally with `git stash`.\n- Local changes you made will be rebased on top of the remote changes.\n- Return your uncommitted changes locally again.\n\n```sh\ngit pull \u003cremote_origin\u003e \u003ctarget_branch\u003e --rebase --autostash\n```\n\n_**Tip:** Skip `--rebase` if you want to merge your changes with the remote changes._\n\n## Pushing\n\n#### Push changes to remote server\n\n```sh\ngit push \u003cremote_origin\u003e \u003cbranch_name\u003e\n```\n\n## Logging\n\n#### Show log info of last commit \n\n```sh\ngit log -1 HEAD\n```\n\n#### Show logs in a fancy way\n\n```sh\ngit log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)\u003c%an\u003e%Creset' --abbrev-commit\n```\n\n## Tagging\n\n#### Create a tag\n\n```sh\ngit tag v1.0.0\n```\n\n#### Delete a tag\n\n```sh\ngit tag -d v1.0.0\n```\n\n## Reflog\n\n#### Find and manage the history of all your Git stuff\n\n```sh\ngit reflog\n```\n\n## Resolve conflicts\n\nTODO\n\n## Aliases\n\nIf you don't want to type the entire text of each of the Git commands above, you can easily set up an alias for each command and then just run it.\n\n__Example:__ We will create an alias `last` that shows log info of the last commit.\n\n```sh\ngit config --global alias.last 'log -1 HEAD'\n```\n\nThen just run:\n\n```sh\ngit last\n```\n\n## Bonus\n\n- [git-useful-aliases](https://github.com/joseluisq/git-useful-aliases) — Set of useful Git aliases.\n- [GitNow](https://github.com/joseluisq/gitnow) — Speed up your Git workflow.\n\n## Resources\n\n- https://git-scm.com/docs\n- https://github.com/nvie/gitflow\n- https://github.com/jakubpawlowicz/git-cheat-sheet\n- https://github.com/git-tips/tips\n- https://github.com/razzius/git-tricks\n\n## Contributions\n\nFeel free to send some [Pull request](https://github.com/joseluisq/git-cheat-sheet/pulls) or [issue](https://github.com/joseluisq/git-cheat-sheet/issues).\n\n## License\n\n[![CC0](https://licensebuttons.net/p/zero/1.0/88x31.png)](http://creativecommons.org/publicdomain/zero/1.0/)\n\nTo the extent possible under law, [Jose Quintana](https://git.io/joseluisq) has waived all copyright and related or neighboring rights to this work.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoseluisq%2Fgit-cheat-sheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoseluisq%2Fgit-cheat-sheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoseluisq%2Fgit-cheat-sheet/lists"}