{"id":20647472,"url":"https://github.com/gvelasq/git-reference","last_synced_at":"2026-05-27T18:32:50.712Z","repository":{"id":115681873,"uuid":"460260749","full_name":"gvelasq/git-reference","owner":"gvelasq","description":"Git command reference","archived":false,"fork":false,"pushed_at":"2022-03-28T06:35:41.000Z","size":7,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-09T17:45:53.183Z","etag":null,"topics":["git","reference"],"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/gvelasq.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":"2022-02-17T02:59:46.000Z","updated_at":"2023-08-03T21:31:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"6074fa36-841f-4f3e-80a8-5be637d0f589","html_url":"https://github.com/gvelasq/git-reference","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gvelasq/git-reference","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gvelasq%2Fgit-reference","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gvelasq%2Fgit-reference/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gvelasq%2Fgit-reference/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gvelasq%2Fgit-reference/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gvelasq","download_url":"https://codeload.github.com/gvelasq/git-reference/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gvelasq%2Fgit-reference/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33579665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"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","reference"],"created_at":"2024-11-16T16:32:55.171Z","updated_at":"2026-05-27T18:32:50.694Z","avatar_url":"https://github.com/gvelasq.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# git-reference\n\n\u003e Git command reference\n\n- [terminal](#terminal)\n- [setup](#setup)\n- [state](#state)\n- [branch](#branch)\n- [remote](#remote)\n- [commit](#commit)\n- [stash](#stash)\n- [sync](#sync)\n- [rewrite history](#rewrite-history)\n- [vanquish ghosts](#vanquish-ghosts)\n\n## terminal\n```bash\n# navigate to a particular folder\ncd \"\u003cpath\u003e\"\n# navigate up a folder\ncd ..\n# navigate to your home folder\ncd\n# list items in current folder\nls\n```\n\n## setup\n```bash\n# check global and local git settings\ngit config --global -l\ngit config --local -l\n# configure global git settings\ngit config --global user.name \"\u003cfull-name\u003e\"\ngit config --global user.email \"\u003cemail\u003e\"\ngit config --global core.editor \"nano -w\"\n# configure local git settings\ncd \"\u003cdesired-path-for-local-settings\u003e\"\ngit config --local user.name \"\u003clocal-full-name\u003e\"\ngit config --local user.email \"\u003clocal-email\u003e\"\n# initialize a local git repository\ncd \"\u003cdesired-path\u003e\"\ngit init\n# clone a remote repository\ngit clone \u003chttps-origin-url\u003e\n```\n\n## state\n```bash\n# check git status\ngit status\n# check git log\ngit log                # verbose\ngit log --oneline      # condense each commit to a single line\ngit log --oneline -n 5 # print only the last 5 commits\n```\n\n## branch\n```bash\n# list all local branches\ngit branch\n# create a local branch\ngit branch \u003clocal-branch-name\u003e\n# switch between branches and update working directory\ngit checkout \u003cbranch-name\u003e\n# delete local branch only if its commits are merged upstream\ngit branch -d \u003clocal-branch-name\u003e\n# delete local branch unconditionally\ngit branch -D \u003clocal-branch-name\u003e\n# delete remote branch\ngit push origin :\u003cremote-branch-name\u003e\n# checkout a pull request\ngit fetch origin pull/\u003cpr-number\u003e/head:\u003cbranch-name\u003e\n# list branches and their creators\ngit for-each-ref --sort=authorname --format \"%(authorname) %(refname)\"\n```\n\n## remote\n```bash\n# view remote settings\ngit remote -v\n# configure 'origin' remote branch\ngit remote add origin \u003chttps-origin-url\u003e\n# change 'origin' remote branch URL\ngit remote set-url origin \u003chttps-origin-url\u003e\n# configure 'upstream' remote branch (when working with a fork)\ngit remote add upstream \u003chttps-origin-url\u003e\n# change 'upstream' remote branch URL\ngit remote set-url upstream \u003chttps-origin-url\u003e\n```\n\n## commit\n```bash\n# stage one file\ngit add \u003cfile.ext\u003e\n# stage all files (danger, this stages all changes)\ngit add .\n# unstage one file\ngit reset HEAD \u003cfile.ext\u003e\n# commit with message\ngit commit -m \"Message\"\n# amend a local commit\ngit commit --amend # this will open up the git editor\n# push local commits to origin\ngit push origin \u003cremote-branch-name\u003e\n```\n\n## stash\n```bash\n# list all stashed files\ngit stash list\n# stash all modified files without committing\ngit stash\n# restore the most recent stashed files\ngit stash pop\n# drop the most recent stashed files\ngit stash drop\n```\n\n## sync\n```bash\n# sync a local fork with changes made in upstream/main\ngit fetch upstream\ngit checkout main\ngit merge upstream/main\ngit push origin main\n# sync a local branch with changes made in origin/main\ngit fetch origin\ngit checkout \u003cbranch-name\u003e\ngit merge origin/main\n```\n\n## rewrite history\n```bash\n# reset local and remote branches to a previous commit\ngit checkout \u003clocal-branch-name\u003e\ngit reset --hard \u003csha-of-last-commit-to-keep\u003e\ngit push -f origin \u003cremote-branch-name\u003e\n```\n\n## vanquish ghosts\n```bash\n# prune remote branches\ngit fetch --prune origin\n# prune upstream branches\ngit fetch --prune upstream\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgvelasq%2Fgit-reference","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgvelasq%2Fgit-reference","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgvelasq%2Fgit-reference/lists"}