{"id":20832957,"url":"https://github.com/udhos/gitcheat","last_synced_at":"2026-06-04T14:31:07.847Z","repository":{"id":75074219,"uuid":"141721883","full_name":"udhos/gitcheat","owner":"udhos","description":null,"archived":false,"fork":false,"pushed_at":"2019-09-25T16:58:15.000Z","size":43,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-15T11:50:48.573Z","etag":null,"topics":["dvcs","git","vcs","versioning"],"latest_commit_sha":null,"homepage":null,"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/udhos.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":"2018-07-20T14:28:15.000Z","updated_at":"2019-09-25T16:58:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"d303704f-d407-49bf-97b6-c75e7ef3c53d","html_url":"https://github.com/udhos/gitcheat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/udhos/gitcheat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udhos%2Fgitcheat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udhos%2Fgitcheat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udhos%2Fgitcheat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udhos%2Fgitcheat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/udhos","download_url":"https://codeload.github.com/udhos/gitcheat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/udhos%2Fgitcheat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28003963,"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-12-24T02:00:07.193Z","response_time":83,"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":["dvcs","git","vcs","versioning"],"created_at":"2024-11-18T00:13:49.469Z","updated_at":"2025-12-24T15:10:50.142Z","avatar_url":"https://github.com/udhos.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# gitcheat\n\n# Table of Contents \n\n* [gitcheat](#gitcheat)\n  * [Config](#config)\n  * [Clone](#clone)\n  * [Index / Staging Area](#index--staging-area)\n  * [Add](#add)\n  * [Rm](#rm)\n  * [Diff](#diff)\n  * [Commit](#commit)\n  * [Log](#log)\n  * [Unstage](#unstage)\n  * [Discard changes in working directory](#discard-changes-in-working-directory)\n  * [Remote](#remote)\n    * [Inspecting remote](#inspecting-remote)\n    * [Renaming remote](#renaming-remote)\n    * [Deleting remote](#deleting-remote)\n  * [Remote branch](#remote-branch)\n    * [Tracking branches](#tracking-branches)\n    * [Deleting remote branch](#deleting-remote-branch)\n  * [Fetch](#fetch)\n  * [Push](#push)\n  * [Tag](#tag)\n    * [Checking out tag](#checking-out-tag)\n  * [Branch](#branch)\n  * [Merge](#merge)\n  * [Pull](#pull)\n  * [Rebase](#rebase)\n  * [Head](#head)\n* [References](#references)\n\nCreated by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc.go)\n\n![commit](img/commit.png)\n\n## Config\n\n    git config --global user.name udhos\n    git config --global user.email udhos\n    git config --global credential.helper 'cache --timeout 3600'\n    git config -l\n\n## Clone\n\n    git clone \u003curl\u003e\n\n\"by default, the git clone command automatically sets up your local master branch to track the remote master branch (or whatever the default branch is called) on the server you cloned from. Running git pull generally fetches data from the server you originally cloned from and automatically tries to merge it into the code you’re currently working on.\"\n\nGit clone by default creates a remote called origin: \"you should at least see origin - that is the default name Git gives to the server you cloned from\"\n\n## Index / Staging Area / Cache\n\n\"Staged means that you have marked a modified file in its current version to go into your next commit snapshot.\"\n\n    git add \u003cfiles\u003e ;# \"add this content to staging area\". The staging area is the full content for the next commit.\n\n## Add\n\n    git add \u003cfiles\u003e ;# \"add precisely this content to the next commit\"\n\n\"Adding the -a option to the git commit command makes Git automatically stage every file that is already tracked before doing the commit, letting you skip the git add part\"\n\n## Rm\n\n    git rm          ;# remove file from working directory and also from staging area\n\n    git rm --cached ;# keep file in working directory but remove it from staging area\n\n## Diff\n\n    git diff          ;# to see what is still unstaged\n\n    git diff --cached ;# to see what you’ve staged so far (--staged and --cached are synonyms)\n\n## Commit\n\n    git commit ;# \"records changes to the repository\"\n\n\"Git thinks about its data more like a stream of snapshots.\"\n\ngit commit appends a new snapshot into the stream.\n\n\"Adding the -a option to the git commit command makes Git automatically stage every file that is already tracked before doing the commit, letting you skip the git add part\"\n\n    git commit --amend ;# redo the last commit\n\n    git commit -m 'message'\n    git add forgotten_file\n    git commit --amend\n\n## Log\n\n    git log ;# \"lists the commits made in that repository in reverse chronological order\"\n\n## Unstage\n\n    git add CONTRIBUTING.md        ;# add CONTRIBUTING.md to stage/index\n    git reset HEAD CONTRIBUTING.md ;# remove CONTRIBUTING.md from stage/index\n\n## Discard changes in working directory\n\n    git checkout -- CONTRIBUTING.md ;# retrieve file from last commit, discarding changes in the working directory\n\n## Remote\n\nRemote is a pointer to a remote repository URL.\n\n    git remote add \u003cshortname\u003e \u003curl\u003e\n\n\"you should at least see origin - that is the default name Git gives to the server you cloned from\"\n\n    $ git remote -v\n    origin  https://github.com/udhos/gitcheat (fetch)\n    origin  https://github.com/udhos/gitcheat (push)\n\n\"git remote add origin git@github.com:peter/first_app.git creates a new remote called origin located at git@github.com:peter/first_app.git. Once you do this, in your push commands, you can push to origin instead of typing out the whole URL\"\n\nhttps://stackoverflow.com/questions/5617211/what-is-git-remote-add-and-git-push-origin-master/5617350#5617350\n\n    git push origin master\n    # push the commits in the local branch named master to the remote named origin\n\nExample:\n\n    git remote add pb https://github.com/paulboone/ticgit\n    git fetch pb = fetch all the information that Paul has but that you don’t yet have in your repository\n    Paul’s master branch is now accessible locally as pb/master\n\n### Inspecting remote\n\n    git remote show \u003cremote\u003e\n\n### Renaming remote\n\n    git remote rename \u003cold\u003e \u003cnew\u003e\n\n### Deleting remote\n\n    git remote rm \u003cremote\u003e\n\n## Remote branch\n\n\"It’s important to note that when you do a fetch that brings down new remote-tracking branches, you don’t automatically have local, editable copies of them. In other words, in this case, you don’t have a new serverfix branch - you only have an origin/serverfix pointer that you can’t modify. To merge this work into your current working branch, you can run git merge origin/serverfix. If you want your own serverfix branch that you can work on, you can base it off your remote-tracking branch:\"\n\n    $ git fetch origin\n     * [new branch]      serverfix    -\u003e origin/serverfix\n\n    $ git checkout -b serverfix origin/serverfix\n\n### Tracking branches\n\n\"When you clone a repository, it generally automatically creates a master branch that tracks origin/master.\"\n\n    git checkout -b serverfix origin/serverfix ;# set branch serverfix tracking remote branch serverfix from origin\n\n    git checkout --track origin/serverfix      ;# shortcut for doing the same\n\n    git checkout serverfix                     ;# even shorter\n\n    git checkout -b sf origin/serverfix        ;# set branch sf tracking remote branch serverfix from origin\n\n    git branch -u origin/serverfix             ;# set remote branch for a local branch\n\n    git fetch --all ;#  fetch from all your remotes \n\n    git branch -vv ;# show remote tracking\n\n### Deleting remote branch\n\n    git branch -d serverfix            ;# delete branch locally\n\n    git push origin --delete serverfix ;# delete branch from remote origin\n\n## Fetch\n\n    git fetch \u003cremote\u003e\n\n\"The command goes out to that remote project and pulls down all the data from that remote project that you don’t have yet. After you do this, you should have references to all the branches from that remote, which you can merge in or inspect at any time.\"\n\n\"git fetch command only downloads the data to your local repository - it doesn’t automatically merge it with any of your work or modify what you’re currently working on.\"\n\n## Push\n\nPush your work upstream.\n\n    git push \u003cremote\u003e \u003cbranch\u003e\n\n## Tag\n\n\"A lightweight tag is very much like a branch that doesn’t change - it’s just a pointer to a specific commit.\"\n\n\"Annotated tags are stored as full objects in the Git database. They’re checksummed; contain the tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG).\"\n\nList tags:\n\n    git tag\n\nShow tag:\n\n    git show v1.4\n\nAnnotated tag:\n\n    git tag -a v1.4 -m \"my version 1.4\"\n\nLightweight tag:\n\n    git tag v1.4-lw\n\nTagging specific commit:\n\n    git tag -a v1.2 9fceb02\n\nSharing specific tag:\n\n    git push origin \u003ctagname\u003e\n\nSharing all tags:\n\n    git push origin --tags\n\nDelete tag:\n\n    git tag --delete \u003ctagname\u003e         ;# delete locally\n    git push --delete origin \u003ctagname\u003e ;# delete tag from remote\n\n### Checking out tag\n\n    git checkout v2.0.0 ;# Puts repository in \"detached HEAD\" state\n\n    git checkout -b version2 v2.0.0 ;# Create branch version2 based on tag v2.0.0\n\n## Branch\n\n\"A branch in Git is simply a lightweight movable pointer to one of these commits. The default branch name in Git is master.\"\n\n\"The master branch in Git is not a special branch. It is exactly like any other branch. The only reason nearly every repository has one is that the git init command creates it by default and most people don’t bother to change it.\"\n\nSee where branch pointers are pointing:\n\n    git log --oneline --decorate\n\nShow branches:\n\n    git branch -a\n\nShow last commit from every branch:\n\n    git branch -vv\n\nCreate branch:\n\n    git branch testing\n\nSwitch to branch: Switching branches changes files in your working directory\n\n    git checkout testing\n\nCreate and switch to branch:\n\n    git checkout -b \u003cbranch\u003e\n\nDelete branch:\n\n    git branch -d \u003cbranch\u003e\n\nShow divergent history:\n\n    git log --oneline --decorate --graph --all\n\n## Merge\n\nBasic merge:\n\n    git checkout master\n    git merge \u003cbranch\u003e\n\n\"The useful --merged and --no-merged options can filter this list to branches that you have or have not yet merged into the branch you’re currently on.\"\n\n    git branch --merged    ;# which branches are already merged into the branch you’re on\n    git branch --no-merged ;# branches that contain work you haven’t yet merged in\n\n## Pull\n\n    git fetch \u003curl\u003e ;# get all changes from server, don't modify the working dir\n\n    git pull ;# look up what server and branch your current branch is tracking, fetch from that server and then try to merge in that remote branch.\n\n\"Generally it’s better to simply use the fetch and merge commands explicitly as the magic of git pull can often be confusing.\"\n\n## Rebase\n\nBasic rebase:\n\n    git checkout experiment\n    git rebase master\n    # replayed experiment on top of master\n\n    git checkout master\n    git merge experiment\n    # master fast-forwarded to experiment\n\nMerge vs Rebase: \"In general the way to get the best of both worlds is to rebase local changes you’ve made but haven’t shared yet before you push them in order to clean up your story, but never rebase anything you’ve pushed somewhere.\"\n\n## Head\n\nA head is simply a reference to a commit object.\n“HEAD” (uppercase) refers exclusively to the currently active head.\n\n    $ cat .git/HEAD\n    ref: refs/heads/master\n\n\"Notice the * character that prefixes the master branch: it indicates the branch that you currently have checked out (i.e., the branch that HEAD points to). This means that if you commit at this point, the master branch will be moved forward with your new work.\"\n\n    git branch\n    * master\n\n# References\n\nhttp://marklodato.github.io/visual-git-guide/index-en.html\n\nhttp://onlywei.github.io/explain-git-with-d3/\n\nhttps://blog.osteele.com/2008/05/my-git-workflow/\n\nhttps://git-scm.com/book/en/v2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fudhos%2Fgitcheat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fudhos%2Fgitcheat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fudhos%2Fgitcheat/lists"}