{"id":15881565,"url":"https://github.com/hackjutsu/cheatsheet","last_synced_at":"2025-04-02T05:43:19.007Z","repository":{"id":83185163,"uuid":"23089540","full_name":"hackjutsu/Cheatsheet","owner":"hackjutsu","description":null,"archived":false,"fork":false,"pushed_at":"2016-03-31T19:41:39.000Z","size":71,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-07T20:23:15.026Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/hackjutsu.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":"2014-08-18T23:08:48.000Z","updated_at":"2025-01-11T06:36:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"9dd473ac-8301-45ce-ad3b-20d816ccf97d","html_url":"https://github.com/hackjutsu/Cheatsheet","commit_stats":{"total_commits":47,"total_committers":6,"mean_commits":7.833333333333333,"dds":0.5957446808510638,"last_synced_commit":"9656ef523802cf6e81bfa87efd5e13bec661a681"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackjutsu%2FCheatsheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackjutsu%2FCheatsheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackjutsu%2FCheatsheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackjutsu%2FCheatsheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hackjutsu","download_url":"https://codeload.github.com/hackjutsu/Cheatsheet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246763860,"owners_count":20829798,"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":[],"created_at":"2024-10-06T03:42:23.786Z","updated_at":"2025-04-02T05:43:18.986Z","avatar_url":"https://github.com/hackjutsu.png","language":"Java","readme":"\n# Quick Reference for Git Commands\n\n\u003cimg src=\"https://github.com/hackjustu/Cheatsheet/blob/master/git_tree.png\" width=\"450\"\u003e\n\n**Set up a new repository**\n\n```bash\ngit init\ngit pull https://github.com/registercosmo/Cheatsheet.git\ngit remote add origin https://github.com/registercosmo/Cheatsheet.git\ngit add .\ngit status\ngit commit\ngit commit -m \"comments\"\ngit push -u origin master\n```\n\n**Sync with the remote repository**\n\n```bash\n# To pull changes to workspace (= fetch + merge)\ngit pull origin master\n\n# To fetch lastest changes from other developers to local repo\ngit fetch \u003cremote_name\u003e\n\n# To merge the local repo and the workspace\ngit merge origin master\n```\n\n**Fix the previous commit**\n\n```bash\ngit commit --amend\n```\n\n**Undo changes**\n\n```bash\n# unstage changes but keep the local changes in the working space\ngit reset HEAD\n\n# discard all the changes in the stage and working space, and match the working space the commit B\ngit reset --hard B\n\n# move the HEAD to commit B, no modification will be made to the stage and the working space\ngit reset --soft B\n```\n\n**Untrack files**\n\n```bash\ngit rm --cached \u003cfile_name\u003e\n```\n\n**Set up remote repositories**\n\n```bash\n# set up a new remote repo (origin)\ngit remote add origin \u003cnew repo url\u003e\n\n# change URL for a remote repo (origin)\ngit remote set-url origin \u003cnew repo url\u003e\n\n# list all the remote repositories URLs\ngit remote -v\n```\n\n**About Configs**\n\n```bash\n# configurations for all repositories\ngit config --global user.name # check current global user.name\ngit config --global user.name \u003cMy username\u003e\ngit config --gloabl user.email=myemail@example.com\n\n# configurations for local repository\ngit config user.name # check current local user.name\ngit config user.name \u003cMy username\u003e\ngit config -user.email=myemail@example.com\n\n# list all the configs\ngit config --list\n\n# Remove the configs\ngit config --global --unset-all user.name # global\n\n# Change the configs\ngit config --global --replace-all user.name \u003cNew User Name\u003e # global\n```\n\n\n**About Branches**\n\n```bash\n# fetch remote branches from Github\ngit remote add origin \u003cULR\u003e # we have to set origin first\ngit pull # It will pull(fetch + merge) all available branches from repositories\n\n# check info for all available branches\ngit branch\n\n# create a new branch\ngit branch  \u003cnew_branch_name\u003e\n\n# switch to a specific branch\ngit checkout  \u003cnew_branch_name\u003e\n\n# create and switch to a new branch\ngit checkout -b \u003cnew_branch_name\u003e\n\n# check the current branch\ngit status\n\n# rename a branch\ngit branch -m \u003cold_branch_name\u003e \u003cnew_branch_name\u003e\n\n# merge a specific branch to the current branch\ngit merge \u003canother_branch_name\u003e\n\n# delete a branch locally\ngit branch -d \u003cbranch_name\u003e\n\n# delete a branch remotely\ngit push origin :\u003cbranch_name\u003e\n```\n\n**About diff**\n\n```bash\n# inspect all the modifications between workspace and stage\ngit diff\n\n# inspect all the modifications between stage and local repo\ngit diff --cached\n```\n\n**About resolving conflicts**\n\n```bash\ngit add \u003cresolved file\u003e\n```\n\n**Advanced Topics**\n\n```bash\n# get the SHA-1 key for a specific contents\necho 'test content' | git hash-object -w --stdin\n\n# get the content of a SHA-1 key\ngit cat-file -p \u003ckey\u003e\n\n# get a object type for a SHA-1 key\ngit cat-file -t \u003ckey\u003e\n```\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackjutsu%2Fcheatsheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackjutsu%2Fcheatsheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackjutsu%2Fcheatsheet/lists"}