{"id":4088,"date":"2026-07-05T23:58:52","date_gmt":"2026-07-05T23:58:52","guid":{"rendered":"https:\/\/wiki.thomasandsofia.com\/?p=4088"},"modified":"2026-07-06T00:24:55","modified_gmt":"2026-07-06T00:24:55","slug":"git-commands","status":"publish","type":"post","link":"https:\/\/wiki.thomasandsofia.com\/?p=4088","title":{"rendered":"Git Commands"},"content":{"rendered":"<p><iframe loading=\"lazy\" title=\"Git &amp; GitHub Crash Course for Beginners [2026]\" width=\"900\" height=\"506\" src=\"https:\/\/www.youtube.com\/embed\/mAFoROnOfHs?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<p>0:52:00<\/p>\n<h2>Branching<\/h2>\n<p><a href=\"https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2026\/07\/Screenshot-from-2026-07-05-17-57-53.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4090\" src=\"https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2026\/07\/Screenshot-from-2026-07-05-17-57-53.png\" alt=\"\" width=\"1291\" height=\"395\" srcset=\"https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2026\/07\/Screenshot-from-2026-07-05-17-57-53.png 1291w, https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2026\/07\/Screenshot-from-2026-07-05-17-57-53-300x92.png 300w, https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2026\/07\/Screenshot-from-2026-07-05-17-57-53-1024x313.png 1024w, https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2026\/07\/Screenshot-from-2026-07-05-17-57-53-768x235.png 768w, https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2026\/07\/Screenshot-from-2026-07-05-17-57-53-150x46.png 150w\" sizes=\"auto, (max-width: 1291px) 100vw, 1291px\" \/><\/a><\/p>\n<p>Branching allows you to test, review and manage changes before merging them with the main code base.<\/p>\n<p><strong>View all branches<\/strong><\/p>\n<pre>git branch<\/pre>\n<p><strong>Create a new branch<\/strong><\/p>\n<p>This makes an exact copy of the current branch<\/p>\n<pre>git branch &lt;branch&gt;<\/pre>\n<p><strong>To use a specific branch<\/strong><\/p>\n<pre>git checkout &lt;branch&gt;<\/pre>\n<p><strong>Merging branches<\/strong><\/p>\n<p>This will merge the branch you specify into the current branch you are working in.<\/p>\n<pre>git merge &lt;branch&gt; -m \"message\"<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2>Commit Commands<\/h2>\n<p>Commit staging to production<\/p>\n<pre>git commit -m \"you message here\"<\/pre>\n<p>Revert back to previous commit<\/p>\n<pre>git reset HEAD~<\/pre>\n<p>View status of changes. See which files will be updated in staging<\/p>\n<pre>git status<\/pre>\n<p>View list of commit changes<\/p>\n<pre>git log\r\ngit log --oneline<\/pre>\n<p>&nbsp;<\/p>\n<h2>Configurations<\/h2>\n<h3>User<\/h3>\n<p>You must have a user configured before you are able to commit.<\/p>\n<h4>Global<\/h4>\n<p>Use this so you do not have to keep typing your email\/name to identify which changes are associated with who made them.<\/p>\n<pre>git config --global user.email \"email@address.com\"\r\ngit config --global user.name \"The Hound\"<\/pre>\n<h4>Local<\/h4>\n<p>These over-ride the global user and can be used per repository<\/p>\n<pre>git config --local user.email \"email@address.com\"\r\ngit config --local user.name \"The Hound\"<\/pre>\n<h2>Deleting Files<\/h2>\n<p>delete file and update stage<\/p>\n<pre>git rm &lt;filename&gt;\r\n# to remove a file that has had uncommitted changes\r\ngit rm -f &lt;filename&gt;<\/pre>\n<p>Remove file from Stage, but keep in working<\/p>\n<pre>git rm --cached &lt;filename&gt;<\/pre>\n<p>Remove a folder recursively<\/p>\n<pre>git rm -r &lt;folder&gt;<\/pre>\n<p>&nbsp;<\/p>\n<h2>Staging<\/h2>\n<h3>Adding files<\/h3>\n<p>Add all files to staging<\/p>\n<pre>git add --all\r\ngit add -A<\/pre>\n<p>Add files from the current folder down<\/p>\n<pre>git add .<\/pre>\n<p>Adds new or modified files but ignore deleted<\/p>\n<pre>git add *<\/pre>\n<h3>Restore staging to previous state<\/h3>\n<p>Only restore to previous state. Does not restore deleted files<\/p>\n<pre>git reset<\/pre>\n<p>Restore deleted files<\/p>\n<pre>git reset --hard<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>0:52:00 Branching Branching allows you to test, review and manage changes before merging them with the main code base. View all branches git branch Create a new branch This makes an exact copy of the current branch git branch &lt;branch&gt; To use a specific branch git checkout &lt;branch&gt; Merging branches This will merge the branch ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/wiki.thomasandsofia.com\/?p=4088\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[87,83],"tags":[],"class_list":["post-4088","post","type-post","status-publish","format-standard","hentry","category-git","category-programming"],"_links":{"self":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/4088","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4088"}],"version-history":[{"count":3,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/4088\/revisions"}],"predecessor-version":[{"id":4093,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/4088\/revisions\/4093"}],"wp:attachment":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}