[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-572760-105":3,"detail-sidebar-cat-1-en-105":81,"doc-detail-572760-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":74,"head_meta":76,"extra_data":78,"updated_unix":80},105,"en","git-cheat-sheet-getting-started-commits-branches-diffs-and-git-config","Git Cheat Sheet - Getting Started, Commits, Branches, Diffs, and Git Config","","A concise Git cheat sheet covering core workflows from repository setup to day-to-day version control. It explains how to initialize and clone repos, inspect status, stage and unstage files, and create commits with messages. It details branch operations, viewing history, comparing commits and diffs, and using blame and search by text changes. It also summarizes Git configuration, common Git file paths, ignore files, cleaning and stashing, history editing, rebasing/merging/cherry-picking, and remote push/pull commands.",{"@graph":14,"@context":73},[15,34,56],{"@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/presentations/","Presentations",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/template/git-cheat-sheet-getting-started-commits-branches-diffs-and-git-config/572760/",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-getting-started-commits-branches-diffs-and-git-config/572760.png","ImageObject",442,249,{"name":42,"@type":43},"Mabel","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-10-20","2026-10-13",true,{"@type":52,"interactionType":53,"userInteractionCount":55},"InteractionCounter",{"@type":54},"ViewAction",5,{"@type":57,"mainEntity":58},"FAQPage",[59,65,69],{"name":60,"@type":61,"acceptedAnswer":62},"How do I initialize a new Git repository and clone an existing one?","Question",{"text":63,"@type":64},"Use git init to start a new repository. Use git clone $URL to clone an existing repository.","Answer",{"name":66,"@type":61,"acceptedAnswer":67},"What commands help stage changes and create commits with a message?",{"text":68,"@type":64},"Stage files with git add $FILE or git add . for all. For interactive staging use git add -p. Create commits with git commit and provide a message via git commit -m 'message'.",{"name":70,"@type":61,"acceptedAnswer":71},"How can I compare commits and view diffs between staged and unstaged changes?",{"text":72,"@type":64},"Use git diff $COMMIT_ID $COMMIT_ID or git show $COMMIT_ID for commit-level differences. For working tree diffs use git diff, for staged diffs use git diff --staged, and for unstaged diffs use git diff without staging.","https://schema.org",{"og:url":32,"og:type":75,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":77,"canonical":32},"index,follow",{"doc_id":79,"site_id":7},572760,1792237907,{"code":4,"msg":82,"data":83},"success",[84,88,93,98,103,108,113,118,122],{"id":85,"doc_module":22,"doc_module_name":25,"category_name":29,"show_sort_weight":86,"slug":87},11,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":55,"slug":121},21,"Paper Templates","papers-templates",{"id":123,"doc_module":22,"doc_module_name":25,"category_name":124,"show_sort_weight":4,"slug":125},158,"General","general-158",{"code":4,"msg":82,"data":127},{"doc_id":79,"user_id":128,"nickname":42,"user_avatar":129,"doc_module":22,"category_id":85,"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":55,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":22,"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":4},7971474920318,"https://ap-avatar.wpscdn.com/avatar/74000ee537e6b0ca360?x-image-process=image/resize,m_fixed,w_180,h_180&k=1788430171632181674","getting started start a new repo:  \ngit init  \nclone an existing repo:  \ngit clone $URL  \nknow where you are  \ngit status  \nprepare to commit  \nadd untracked file:(or unstaged changes)  \ngit add $FILE  \nadd ALL untracked files and unstaged changes:  \ngit add .  \nchoose which parts of a file to stage:  \ngit add -p  \ndelete or move file:  \ngit rm $FILE  \ngit mv $OLD $NEW  \ntell git to forget about a file without deleting it:  \ngit rm --cached $FILE  \nunstage everything:  \ngit reset HEAD  \nmake commits  \nmake a commit:(and open a text editor to write the message)  \ngit commit  \nmake a commit:  \ngit commit -m 'message'  \ncommit all unstaged changes:  \ngit commit -am 'message'  \nmove between branches  \nswitch branches:  \ngit switch $NAME OR  \ngit checkout $NAME  \ncreate a branch: git switch -c $NAME ORgit checkout -b $NAME  \nlist branches:  \ngit branch  \ndelete a branch  \ngit branch -d $NAME  \nforce delete a branch:  \ngit branch -D $NAME  \nlist branches by most recently committed to:  \ngit branch--sort=-committerdate  \nlook at a branch's history  \nlog the branch  \ngit log main  \nshow how two branches relate to each other:  \ngit log --graph a b  \none line log:  \ngit log --oneline  \ncode archaeology  \nshow who last changed each line of a file:  \ngit blame $FILENAME  \nshow every commit that modified a file:  \ngit log $FILENAME  \nfind every commit that added or removed some text:  \ngit log -S banana  \ndiff commits  \nshow diff between a commit and its parent:  \ngit show $COMMIT_ID  \nshow diff between a merge commit and its merged parents:  \ngit show --remerge-diff  \n$COMMIT_ID  \ndiff two commits:  \ngit diff $COMMIT_ID $COMMIT_ID  \njust show diff for one file:  \ngit diff $COMMIT_ID $FILENAME  \nshow a summary of a diff:  \ngit diff $COMMIT_ID --stat git show $COMMIT_ID --stat  \ndiff staged/unstaged changes  \ndiff all staged and unstaged changes:  \ngit diff HEAD  \ndiff just staged changes:  \ngit diff --staged  \ndiff just unstaged changes:  \ngit diff  \nconfigure git  \nset a config option:  \ngit config [user.name](user.name) 'Jul ia'  \nname value  \nsee all possible config options:  \nman git-config  \nset option globally:  \ngit config --global ...  \nadd an alias:  \ngit config [alias.st](alias.st) status  \nimportant git files local git config:  \n.git/config  \nglobal git config:  \n~/.gitconfig  \nlist of files to ignore:  \n.gitignore  \ntrash your changes   \ndelete all staged and  \nunstaged changes to one file:  \ngit checkout HEAD $FILE  \ndelete unstaged changes to one file:  \ngit checkout $FILE  \ndelete all staged and unstaged changes:  \ngit reset --hard  \ndelete untracked files:  \ngit clean  \n\"stash\" all staged and unstaged changes (pretend I might get them back later)  \ngit stash  \nedit history   \n\"undo\" the most recent commit (keep your working directory the same):  \ngit reset HEAD^  \nsquash the last 5 commits into one:  \ngit rebase -i HEAD^^^^^^  \nafindxupc\"hafoea\"npyiccko\"mtomit I want to combine with the previous one)  \nundo a failed rebase:  \ngit reflog BRANCHNAME  \ndo a painstaking search  \ngit reset --hard $COMMIT_ID  \nchange a commit message:(or add a file you forgot)  \ngit commit --amend  \nrestore an old file  get the version of a file from another branch or commit  \ngit checkout $COMMIT_ID $FILE  \nOR  \ngit restore $FILE--source $COMMIT_ID  \ncombine diverged branches  \nhow the branches look before:  \nmain  \nbanana  \ncombine with rebase:  \ngit switch banana  \ngit rebase main  \nmain banana  \ncombine with merge:  \ngit switch main  \ngit merge banana  \ngit commit  \nmain  \nbanana  \n combine with squash merge:  \ngit switch main  \ngit merge --squash banana  \ngit commit  \nbanana  \nmain  \nbring a branch up to date  \nwith another branch  \n(aka \"fast-forward merge\")  \nmain banana  \ngit switch main  \ngit merge banana  \nbanana  \n main  \ncopy one commit onto  \nanother branch  \nbefore:  \n  main  \nbanana  \ngit cherry-pick $COMMIT_ID  \nafter: main  \nbanana  \nadd a remote  \ngit remote add $NAME $URL  \npush your changes  \npush the main branch to the remote","cbCaijaJ0GXGwlcW","https://ap.wps.com/l/cbCaijaJ0GXGwlcW","pdf",98741,"English","# Getting started\n## Create and clone repositories\n## Check status and stage changes\n## Commit basics\n# Branches and history\n## Switch, create, and delete branches\n## View commit history and relationships\n## Blame and search commits\n# Diffs and comparisons\n## Commit diffs and staged/unstaged diffs\n## Diff summaries and file-specific diffs\n# Configuration and maintenance\n## git config and common Git files\n## Ignore files and clean/stash changes\n# History editing and integration\n## Reset, amend, and reflog\n## Rebase, merge, and squash merges\n## Cherry-pick and bringing branches up to date\n# Remotes and synchronization\n## Add remotes and push\n## Fetch and pull (merge or rebase)","[{\"question\":\"How do I initialize a new Git repository and clone an existing one?\",\"answer\":\"Use git init to start a new repository. Use git clone $URL to clone an existing repository.\"},{\"question\":\"What commands help stage changes and create commits with a message?\",\"answer\":\"Stage files with git add $FILE or git add . for all. For interactive staging use git add -p. Create commits with git commit and provide a message via git commit -m 'message'.\"},{\"question\":\"How can I compare commits and view diffs between staged and unstaged changes?\",\"answer\":\"Use git diff $COMMIT_ID $COMMIT_ID or git show $COMMIT_ID for commit-level differences. For working tree diffs use git diff, for staged diffs use git diff --staged, and for unstaged diffs use git diff without staging.\"}]","Git Cheat Sheet - Getting Started, Commits, Branches, Diffs, and Git Config | PDF",1791929156]