[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-573216-105":3,"detail-sidebar-cat-1-en-105":80,"doc-detail-573216-en":126},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":73,"head_meta":75,"extra_data":77,"updated_unix":79},105,"en","git-cheat-sheet-quick-reference","Git Cheat Sheet - Quick Reference","","Git Cheat Sheet provides a practical reference for core Git workflows and commands. It covers initializing repositories, cloning remote or local projects, configuring author identity, staging and committing changes, and checking repository status. It also explains reading commit history with git log and comparing changes with git diff. Additional sections address undoing changes via revert and reset/clean, rewriting history through amend and rebase, managing branches, and using remote operations like add, fetch, pull, and push.",{"@graph":14,"@context":72},[15,34,55],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/template/","Template",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/template/general/","General",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/template/git-cheat-sheet-quick-reference/573216/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/git-cheat-sheet-quick-reference/573216.png","ImageObject",442,249,{"name":42,"@type":43},"Liam","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-10-16","2026-10-13",true,{"@type":52,"interactionType":53,"userInteractionCount":30},"InteractionCounter",{"@type":54},"ViewAction",{"@type":56,"mainEntity":57},"FAQPage",[58,64,68],{"name":59,"@type":60,"acceptedAnswer":61},"How do I initialize a new Git repository?","Question",{"text":62,"@type":63},"Use `git init \u003Cdirectory>` to create an empty Git repo in the specified directory. Running `git init` with no arguments initializes the current directory as a Git repository.","Answer",{"name":65,"@type":60,"acceptedAnswer":66},"What commands help undo or reset changes?",{"text":67,"@type":63},"Use `git revert \u003Ccommit>` to create a new commit that undoes changes from the specified commit. Use `git reset` to move the branch tip and reset the staging area, and use `git clean` to remove untracked files.",{"name":69,"@type":60,"acceptedAnswer":70},"How do I work with remotes and synchronize branches?",{"text":71,"@type":63},"Add a remote with `git remote add \u003Cname> \u003Curl>`, then fetch with `git fetch \u003Cremote> \u003Cbranch>` or pull with `git pull \u003Cremote>`. Push changes with `git push \u003Cremote> \u003Cbranch>` to update the remote repository.","https://schema.org",{"og:url":32,"og:type":74,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":76,"canonical":32},"index,follow",{"doc_id":78,"site_id":7},573216,1792090764,{"code":4,"msg":81,"data":82},"success",[83,88,93,98,103,108,113,118,123],{"id":84,"doc_module":22,"doc_module_name":25,"category_name":85,"show_sort_weight":86,"slug":87},11,"Presentations",90,"presentations",{"id":89,"doc_module":22,"doc_module_name":25,"category_name":90,"show_sort_weight":91,"slug":92},12,"Resumes",80,"resumes",{"id":94,"doc_module":22,"doc_module_name":25,"category_name":95,"show_sort_weight":96,"slug":97},14,"Invoices",70,"invoices",{"id":99,"doc_module":22,"doc_module_name":25,"category_name":100,"show_sort_weight":101,"slug":102},15,"Posters",60,"posters",{"id":104,"doc_module":22,"doc_module_name":25,"category_name":105,"show_sort_weight":106,"slug":107},16,"Social Media",50,"social-media",{"id":109,"doc_module":22,"doc_module_name":25,"category_name":110,"show_sort_weight":111,"slug":112},17,"Forms",40,"forms",{"id":114,"doc_module":22,"doc_module_name":25,"category_name":115,"show_sort_weight":116,"slug":117},18,"Letters",30,"letters",{"id":119,"doc_module":22,"doc_module_name":25,"category_name":120,"show_sort_weight":121,"slug":122},21,"Paper Templates",5,"papers-templates",{"id":124,"doc_module":22,"doc_module_name":25,"category_name":29,"show_sort_weight":4,"slug":125},158,"general-158",{"code":4,"msg":81,"data":127},{"doc_id":78,"user_id":128,"nickname":42,"user_avatar":129,"doc_module":22,"category_id":124,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":130,"file_id":131,"file_url":132,"file_type":133,"file_size":134,"view_count":30,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":26,"language":135,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":136,"faqs":137,"seo_title":138,"seo_description":12,"update_tm":139,"read_time":22},8796095461564,"https://ap-avatar.wpscdn.com/davatar_155a257f0dc6eb9ab79c44ca47cae57d","Git Cheat Sheet  \n| Git Basics |  |\n| --- | --- |\n| git init \u003Cdirectory> | Create empty Git repo in specified directory. Run with no arguments to initialize the current directory as a git repository. |\n| git clone \u003Crepo> | Clone repo located at \u003Crepo> onto local machine. Original repo can be located on the local filesystem or on a remote machine via [HTTP](HTTP) or SSH. |\n| git config\u003Cbr>[user.name](user.name) \u003Cname> | Define author name to be used for all commits in current repo. Devs commonly use--global flag to set config options for current user. |\n| git add \u003Cdirectory> | Stage all changes in \u003Cdirectory> for the next commit.\u003Cbr>Replace \u003Cdirectory> with a \u003Cfile> to change a specific file. |\n| git commit-m\"\u003Cmessage>\" | Commit the staged snapshot, but instead of launching a text editor, use \u003Cmessage> as the commit message. |\n| git status | List which files are staged, unstaged, and untracked. |\n| git log | Display the entire commit history using the default format. For customization see additional options. |\n| git diff | Show unstaged changes between your index and working directory. |\n\nUndoing Changes  \ngit revert \u003Ccommit>  \nCreate new commit that undoes all of the changes made in \u003Ccommit>, then apply it to the current branch.  \ngit reset \u003Cfile>  \ngit clean-n  \nRemove \u003Cfile> from the staging area, but leave the working directory unchanged. This unstages a file without overwriting any changes.  \nShows which files would be removed from working directory. Use the-f flag in place of the-n flag to execute the clean.  \n| Rewriting Git History |  |  |\n| --- | --- | --- |\n| git commit--amend |  | Replace the last commit with the staged changes and last commit combined. Use with nothing staged to edit the last commit’s message. |\n| git | rebase \u003Cbase> | Rebase the current branch onto \u003Cbase> . \u003Cbase> can be a commit ID, a branch name, a tag, or a relative reference to HEAD. |\n| git | reflog | Show a log of changes to the local repository’s HEAD. Add\u003Cbr>--relative-date flag to show date info or--all to show all refs. |\n| Git Branches |  |  |\n| git branch |  | List all of the branches in your repo. Add a \u003Cbranch> argument to create a new branch with the name \u003Cbranch>. |\n| git checkout-b \u003Cbranch> |  | Create and check out a new branch named \u003Cbranch>. Drop the-b flag to checkout an existing branch. |\n| git merge \u003Cbranch> Merge \u003Cbranch> into the current branch. |  |  |\n| Remote Repositories |  |  |\n| git remote add \u003Cname> \u003Curl> |  | Create a new connection to a remote repo. After adding a remote, you can use \u003Cname> as a shortcut for \u003Curl> in other commands. |\n| git fetch\u003Cbr>\u003Cremote> \u003Cbranch> |  | Fetches a specific \u003Cbranch>, from the repo. Leave off \u003Cbranch> to fetch all remote refs. |\n| git pull \u003Cremote> |  | Fetch the specified remote’s copy of current branch and immediately merge it into the local copy. |\n| git push\u003Cbr>\u003Cremote> \u003Cbranch> |  | Push the branch to \u003Cremote>, along with necessary commits and objects. Creates named branch in the remote repo if it doesn’t exist. |\n\n[Visit](Visit atlassian.com/git)[ atlassian.com/git](Visit atlassian.com/git) for more information, training, and tutorials  \nAdditional Options +  \ngit config  \ngit config--global [user.name](user.name) \u003Cname>  \nDefine the author name to be used for all commits by the current user.  \ngit config--global [user.email](user.email) \u003Cemail>  \ngit config--global alias. \u003Calias-name>\u003Cgit-command>  \ngit config--system core.editor \u003Ceditor>  \ngit config  \n--global--edit  \nDefine the author email to be used for all commits by the current user.  \nCreate shortcut for a Git command. E.g. alias.glog log--graph--oneline will set git glog equivalent to git log--graph--oneline.  \nSet text editor used by commands for all users on the machine. \u003Ceditor> arg should be the command that launches the desired editor (e.g., vi).  \nOpen the global configuration file in a text editor for manual editing.  \ngit log  \ngit log-\u003Climit>  \nLimit number of commits by \u003Climit>. E.g. git log-5 will limit to","cbCaiuVC7pL65aXW","https://ap.wps.com/l/cbCaiuVC7pL65aXW","pdf",104846,"English","# Git Basics\n## Undoing Changes\n## Rewriting Git History\n## Git Branches\n## Remote Repositories\n## Additional Options","[{\"question\":\"How do I initialize a new Git repository?\",\"answer\":\"Use `git init \\u003cdirectory\\u003e` to create an empty Git repo in the specified directory. Running `git init` with no arguments initializes the current directory as a Git repository.\"},{\"question\":\"What commands help undo or reset changes?\",\"answer\":\"Use `git revert \\u003ccommit\\u003e` to create a new commit that undoes changes from the specified commit. Use `git reset` to move the branch tip and reset the staging area, and use `git clean` to remove untracked files.\"},{\"question\":\"How do I work with remotes and synchronize branches?\",\"answer\":\"Add a remote with `git remote add \\u003cname\\u003e \\u003curl\\u003e`, then fetch with `git fetch \\u003cremote\\u003e \\u003cbranch\\u003e` or pull with `git pull \\u003cremote\\u003e`. Push changes with `git push \\u003cremote\\u003e \\u003cbranch\\u003e` to update the remote repository.\"}]","Git Cheat Sheet - Quick Reference | PDF",1791934849]