{"id":26902647,"url":"https://github.com/touppercase78/useful-git-commands","last_synced_at":"2026-02-03T04:03:13.726Z","repository":{"id":134010716,"uuid":"327892963","full_name":"toUpperCase78/useful-git-commands","owner":"toUpperCase78","description":"Useful Git commands can be found here.","archived":false,"fork":false,"pushed_at":"2023-04-07T15:05:11.000Z","size":1625,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-02T12:05:41.523Z","etag":null,"topics":["cheatsheets","git","useful"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/toUpperCase78.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-01-08T12:11:24.000Z","updated_at":"2023-04-10T10:12:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"0bbb6499-1237-4551-bf96-5fbeab442d53","html_url":"https://github.com/toUpperCase78/useful-git-commands","commit_stats":null,"previous_names":["touppercase78/useful-git-commands"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/toUpperCase78/useful-git-commands","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toUpperCase78%2Fuseful-git-commands","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toUpperCase78%2Fuseful-git-commands/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toUpperCase78%2Fuseful-git-commands/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toUpperCase78%2Fuseful-git-commands/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toUpperCase78","download_url":"https://codeload.github.com/toUpperCase78/useful-git-commands/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toUpperCase78%2Fuseful-git-commands/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261006037,"owners_count":23095966,"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":["cheatsheets","git","useful"],"created_at":"2025-04-01T09:53:14.012Z","updated_at":"2026-02-03T04:03:13.649Z","avatar_url":"https://github.com/toUpperCase78.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# useful-git-commands\n\nI've seen lots of cheat sheets from various sources ion the Internet, presents many commands related to Git version control. Here are the most useful ones below:\n\n_Also uploaded Git Cheat Sheets images that explain the commands with some visuals. Be sure to check them out above!_\n\n### CREATE\n\nClone an existing repository: `$ git clone \u003cgithub_url\u003e`\n\nCreate a new local repository: `$ git init`\n\n### LOCAL CHANGES\n\nSee the latest status in your working directory: `$ git status`\n\nSee changes to tracked files: `$ git diff`\n\nSee changes between two commits: `$ git diff \u003ccommit_ID1\u003e \u003commit_ID2\u003e`\n\nAdd all current changes to the next commit: `$ git add .`\n\nAdd some changes in file to the next commit: `$ git add -p \u003cfile\u003e`\n\nCommit all local changes in tracked files: `$ git commit -a`\n\nCommit previously staged changes: `$ git commit`\n\nCommit staged changes with a message: `$ git commit -m \u003cmessage\u003e`\n\nAll all changes made to tracked files and commit: `$ git commit -am \u003cmessage\u003e`\n\nChange the last commit: `$ git commit --amend`\n\n### COMMIT HISTORY\n\nShow all commits, starting with the newest on top: `$ git log`\n\nShow changes over time for a specific file: `$ git log -p \u003cfile\u003e`\n\nWho changed what and when in file: `$ git blame \u003cfile\u003e`\n\n### BRANCHES \u0026 TAGS\n\nList all existing branches: `$ git branch`\n\nSwitch to the branch: `$ git checkout \u003cbranch\u003e`\n\nCreate a new branch based on your current HEAD: `$ git branch \u003cnew_branch\u003e`\n\nCreate a new branch and switch to it: `$ git checkout -b \u003cnew_branch\u003e`\n\nCreate a new tracking branch based on a remote branch: `$ git checkout --track \u003cremote/branch\u003e` \n\nDelete a local branch: `$ git branch -d \u003cbranch\u003e`\n\nMark the current commit with a tag: `$ git tag \u003ctag_name\u003e`\n\n### UPDATE \u0026 PUBLISH\n\nList all currently configured remotes: `$ git remote -v`\n\nShow information about a remote: `$ git remote show \u003cremote\u003e`\n\nAdd new remote repository, named 'remote': `$ git remote add \u003cshortname\u003e \u003curl\u003e`\n\nDownload all changes from 'remote', but don't integrate into HEAD: `$ git fetch \u003cremote\u003e`\n\nDownload changes and directly merge/integrate into HEAD: `$ git pull \u003cremote\u003e \u003cbranch\u003e`\n\nPublish local changes on a remote: `$ git push \u003cremote\u003e \u003cbranch\u003e`\n\nDelete a branch on the remote: `$ git branch -dr \u003cremote/branch\u003e`\n\nPublish your tags: `$ git push --tags`\n\n### MERGE \u0026 REBASE\n\nMerge branch into your current HEAD: `$ git merge \u003cbranch\u003e`\n\nRebase your current HEAD onto branch: `$ git rebase \u003cbranch\u003e`\n\nAbort a rebase: `$ git rebase --abort`\n\nContinue a rebase after resolving conflicts: `$ git rebase --continue`\n\nUser your configured merge tool to solve conflicts: `$ git mergetool`\n\n### UNDO\n\nMove/rename a file and stage move: `$ git mv \u003cexisting_path\u003e \u003cnew_path\u003e`\n\nRemove a file from working directory and staging area, then stage the removal: `$ git rm \u003cfile\u003e`\n\nRemove from staging area only: `$ git rm --cached \u003cfile\u003e`\n\nDiscard all local changes in your working directory: `$ git reset --hard HEAD`\n\nDiscard local changes in a specific file: `$ git checkout HEAD \u003cfile\u003e`\n\nRevet a commit (by producing a new commit with contrary changes): `$ git revert \u003ccommit\u003e`\n\nReset your HEAD pointer to a previous commit and discard all changes since then: `$ git reset --hard \u003ccommit\u003e`\n\nAnd preserve all changes as unstaged changes: `$ git reset \u003ccommit\u003e`\n\nAnd preserve uncommitted local changes: `$ git reset --keep \u003ccommit\u003e`\n\n## Previously...\n\nI had performed a demonstration to push files from my local repository to this remote repo here.\n\nIt worked by using `git push`, including two other git commands beforehand: `remote` and `branch`\n\nThese commands had been entered inside git bash while in my local directory:\n\n* `git remote add origin \u003cclone-url\u003e`\n* `git branch -M main`\n* `git push -u origin main`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftouppercase78%2Fuseful-git-commands","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftouppercase78%2Fuseful-git-commands","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftouppercase78%2Fuseful-git-commands/lists"}