{"id":41957,"date":"2023-10-03T07:00:45","date_gmt":"2023-10-03T14:00:45","guid":{"rendered":"https:\/\/dhblog.dream.press\/blog\/?p=41957"},"modified":"2025-05-21T16:11:16","modified_gmt":"2025-05-21T23:11:16","slug":"git-commands","status":"publish","type":"post","link":"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/","title":{"rendered":"Git Commands: 21 Must-Know Options"},"content":{"rendered":"\n<p>Anyone who uses Git,&nbsp;or has even <i>seen<\/i> it for that matter,&nbsp;knows there are a <b>lot<\/b> of terms and modifiers to keep up with.<\/p>\n\n\n\n<p>And keep up, you must, as it\u2019s become the standard in version control for tech products today.<\/p>\n\n\n\n<p>But instead of just expecting you to keep it <i>all<\/i> in your head, we put together this go-to resource full of critical commands for you to reference so you can use Git both effectively and efficiently.<\/p>\n\n\n\n<p>Not a Git super user (<i>yet<\/i>)? That\u2019s perfectly fine.<\/p>\n\n\n\n<p>The commands we\u2019ll detail here range from the everyday to the more rare and complex. And, as an added bonus, each is joined by tips on ways you can use it during a development project.<\/p>\n\n\n\n<p>We\u2019ll kick things off with some info on Git\u2019s background, then wrap up with a full walkthrough of how you might use Git in a real-life setting.<\/p>\n\n\n\n<h2 id=\"introduction\" class=\"wp-block-heading\">Quick Debrief: Understanding Git, GitHub, &amp; Version Control<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1600\" height=\"900\" data-src=\"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/Git.jpg\" alt=\"Git is a Source Code Management (SCM) platform\" class=\"wp-image-41964 lazyload\" data-srcset=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Git.jpg.webp 1600w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/Git-300x169.jpg 300w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/Git-1024x576.jpg 1024w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/Git-768x432.jpg 768w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/Git-1536x864.jpg 1536w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Git-600x338.jpg.webp 600w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Git-1200x675.jpg.webp 1200w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Git-730x411.jpg.webp 730w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Git-1460x821.jpg.webp 1460w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Git-784x441.jpg.webp 784w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Git-1568x882.jpg.webp 1568w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Git-877x493.jpg.webp 877w\" data-sizes=\"(max-width: 1600px) 100vw, 1600px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1600px; --smush-placeholder-aspect-ratio: 1600\/900;\" \/><\/figure>\n\n\n\n<p><a href=\"https:\/\/git-scm.com\/\" target=\"_blank\" rel=\"noopener\">Git<\/a> is what its builders call a Source Code Management (SCM) platform. In other words, it\u2019s a version control system. One that\u2019s free, easy to use, and thus at the core of many well-known projects.<\/p>\n\n\n\n<p>Which brings us to a logical question if you aren\u2019t immersed in the world of development: What exactly is version control?<\/p>\n\n\n\n<p>Building something from code frequently takes a lot of trial, error, and steps. And, in many cases, collaboration.<\/p>\n\n\n\n<p>It\u2019s easy for important elements that took a lot of effort to get overwritten or lost. For example, if you\u2019ve ever worked with a colleague in a live Google Doc, you understand what we mean.<\/p>\n\n\n\n<p>A version control tool basically saves each iteration of your progress throughout a project. This is helpful in case you want to rewind to a previous version to review and grab certain elements to reuse \u2014&nbsp;or even restore an older version if something in the current build isn\u2019t working as intended.<\/p>\n\n\n\n<p>Git is installed locally, meaning it exists on your computer instead of in the cloud. In fact, you don\u2019t even have to be connected to the internet when using it!<\/p>\n\n\n\n<p>In this way, it provides a secure repository (often called a \u201crepo,\u201d which is a storage space for code) for a developer to save every \u201cdraft\u201d of a project they\u2019re working on.<\/p>\n\n\n\n<p>Git takes this one step further with the branching model for which it has become known.<\/p>\n\n\n\n<p>With Git, a developer can create various code \u201cbranches\u201d that extend from a project. These branches are basically copies of the main project,&nbsp;which used to be called the \u201cmaster\u201d project, but that term is being phased out.<\/p>\n\n\n\n<p>Changes in branches don\u2019t impact the code of the main project unless you tell them to. With branching, developers can do things like experiment with new features or fix bugs. The changes made in a branch won\u2019t impact the main code unless you do something called \u201cmerging.\u201d<\/p>\n\n\n\n<p>Git makes perfect sense for website owners or developers working on their own projects. But what about when you need to work with a team on a coding project?<\/p>\n\n\n\n<p>Meet GitHub.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1600\" height=\"900\" data-src=\"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/GitHub.jpg\" alt=\"GitHub is a development platform for hosting Git repositories\" class=\"wp-image-41965 lazyload\" data-srcset=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub.jpg.webp 1600w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/GitHub-300x169.jpg 300w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/GitHub-1024x576.jpg 1024w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/GitHub-768x432.jpg 768w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/GitHub-1536x864.jpg 1536w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub-600x338.jpg.webp 600w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub-1200x675.jpg.webp 1200w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub-730x411.jpg.webp 730w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub-1460x821.jpg.webp 1460w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub-784x441.jpg.webp 784w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub-1568x882.jpg.webp 1568w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub-877x493.jpg.webp 877w\" data-sizes=\"(max-width: 1600px) 100vw, 1600px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1600px; --smush-placeholder-aspect-ratio: 1600\/900;\" \/><\/figure>\n\n\n\n<p><a href=\"https:\/\/github.com\/\" target=\"_blank\" rel=\"noopener\">GitHub<\/a> is a development platform for hosting Git repositories.<\/p>\n\n\n\n<p>In other words, it\u2019s how you get your Git repos off of your local machine and onto the internet, usually for the purpose of enabling people to collaborate on them.<\/p>\n\n\n\n<p>GitHub is cloud based and for profit, though the basics can be used for free when you sign up.<\/p>\n\n\n\n<p>The primary function of GibHub is enabling developers to work together on a singular project in real time, remotely making code revisions, reviewing each other&#8217;s work, and updating the main project.<\/p>\n\n\n\n<p>GitHub maintains the core feature of Git: preventing overwriting and maintaining each saved version of a project. It also layers in all kinds of additional features and add-ons like increased storage, fast development environments, AI-powered code writing, code auditing support, and much more. (We recommend checking out the <a href=\"https:\/\/github.com\/pricing\" target=\"_blank\" rel=\"noopener\">pricing<\/a> page to see everything on offer.)<\/p>\n\n\n\n<p>It\u2019s important to note that GitHub isn\u2019t the only service in this space. Alternatives include Bitbucket, GitLab, etc.<\/p>\n\n\n\n<p>However, Git and GitHub of course work together like peanut butter and jelly, as you\u2019ll see a little later in this article.<\/p>\n\n\n\n<p>First things first: a complete list of all the Git commands developers and tech teams should be familiar with to find success in this version control environment.<\/p>\n\n\n\n\n\n<div class=\"glossary-term\">\n\t<a\n\t\tclass=\"glossary-term__above-title\"\n\t\thref=\"\"\n\t\ttarget=\"_blank\"\n\t\trel=\"noopener noreferrer\"\n\t>\n\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 640 512\"><path d=\"M320 32c-8.1 0-16.1 1.4-23.7 4.1L15.8 137.4C6.3 140.9 0 149.9 0 160s6.3 19.1 15.8 22.6l57.9 20.9C57.3 229.3 48 259.8 48 291.9v28.1c0 28.4-10.8 57.7-22.3 80.8c-6.5 13-13.9 25.8-22.5 37.6C0 442.7-.9 448.3 .9 453.4s6 8.9 11.2 10.2l64 16c4.2 1.1 8.7 .3 12.4-2s6.3-6.1 7.1-10.4c8.6-42.8 4.3-81.2-2.1-108.7C90.3 344.3 86 329.8 80 316.5V291.9c0-30.2 10.2-58.7 27.9-81.5c12.9-15.5 29.6-28 49.2-35.7l157-61.7c8.2-3.2 17.5 .8 20.7 9s-.8 17.5-9 20.7l-157 61.7c-12.4 4.9-23.3 12.4-32.2 21.6l159.6 57.6c7.6 2.7 15.6 4.1 23.7 4.1s16.1-1.4 23.7-4.1L624.2 182.6c9.5-3.4 15.8-12.5 15.8-22.6s-6.3-19.1-15.8-22.6L343.7 36.1C336.1 33.4 328.1 32 320 32zM128 408c0 35.3 86 72 192 72s192-36.7 192-72L496.7 262.6 354.5 314c-11.1 4-22.8 6-34.5 6s-23.5-2-34.5-6L143.3 262.6 128 408z\"\/><\/svg>\n\t\t<span><\/span>\n\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 384 512\"><path d=\"M342.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L274.7 256 105.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z\"\/><\/svg>\n\t<\/a>\n    <h3>Github<\/h3>\n    <p>GitHub is a cloud-based service developers use to store their code, track new changes, and collaborate with other developers. It is a popular platform for collaborating in real-time on software projects.<\/p>\n            <a\n            href=\"https:\/\/www.dreamhost.com\/glossary\/web-design\/github\/\"\n                        class=\"btn btn--white-outline btn--sm btn--round\"\n                                    target=\"_blank\"\n            rel=\"noopener noreferrer\"\n            >\n                            Read More                    <\/a>\n\n<\/div>\n\n\n\n<h2 id=\"mostused\" class=\"wp-block-heading\">21 Of The Most-Used Git Commands You Should Know<\/h2>\n\n\n\n<p>Are you ready for the ultimate Git cheat sheet?<\/p>\n\n\n\n<p>In this section we\u2019ll dive into the Git commands,&nbsp;instructions, basically,&nbsp;that you need to know to use Git successfully. And, we\u2019ll even throw on some tips on how you may use each of them in a project.<\/p>\n\n\n\n<p><b>Pro tip<\/b> for making the most of this document: Press \u201ccommand + F\u201d on a Mac or \u201cCtrl + F\u201d on Windows to open a search box to find a specific command, if you\u2019re looking for something in particular.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git config<\/code><\/h3>\n\n\n\n<p><code>git config<\/code> is a helpful command for customizing how Git works on three levels: the operating system level (system), user-specific level (global), and repository-specific level (local).<\/p>\n\n\n\n<p>Try out <code>git config<\/code> with these moves:<\/p>\n\n\n\n<p><code>git config --global user.email [your email]<\/code><br>This is a command many devs run right after downloading Git to set up their email address.<\/p>\n\n\n\n<p><code>git config --global user.name [your name]<\/code><br>For setting up your user name.<\/p>\n\n\n\n<p><code>git config --local<\/code><br>Customize your local repository-specific settings. This will override default Git configs at the system and global levels.<\/p>\n\n\n\n<div class=\"article-newsletter article-newsletter--gradient\">\n\n\n<h2>Get Content Delivered Straight to Your Inbox<\/h2><p>Subscribe now to receive all the latest updates, delivered directly to your inbox.<\/p><form class=\"nwsl-form\" id=\"newsletter_block_\" novalidate><div class=\"messages\"><\/div><div class=\"form-group\"><label for=\"input_newsletter_block_\"><input type=\"email\"name=\"email\"id=\"input_newsletter_block_\"placeholder=\"Enter your email address\"novalidatedisabled=\"disabled\"\/><\/label><button type=\"submit\"class=\"btn btn--brand\"disabled=\"disabled\"><span>Sign Me Up!<\/span><svg width=\"21\" height=\"14\" viewBox=\"0 0 21 14\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n<path d=\"M13.8523 0.42524L12.9323 1.34521C12.7095 1.56801 12.7132 1.9304 12.9404 2.14865L16.7241 5.7823H0.5625C0.251859 5.7823 0 6.03416 0 6.3448V7.6573C0 7.96794 0.251859 8.2198 0.5625 8.2198H16.7241L12.9405 11.8535C12.7132 12.0717 12.7095 12.4341 12.9323 12.6569L13.8523 13.5769C14.072 13.7965 14.4281 13.7965 14.6478 13.5769L20.8259 7.39879C21.0456 7.17913 21.0456 6.82298 20.8259 6.60327L14.6477 0.42524C14.4281 0.205584 14.0719 0.205584 13.8523 0.42524Z\" fill=\"white\"\/>\n<\/svg>\n<\/button><\/div><\/form><\/div>\n\n\n<h3 class=\"wp-block-heading\"><code>git pull<\/code><\/h3>\n\n\n\n<p><code>git pull<\/code> is your command for fetching code from a remote repo and downloading it to your local repo,&nbsp;which will then be updated to match what you just pulled.<\/p>\n\n\n\n<p>This act of merging is foundational to using Git. And, it\u2019s actually \u201cshorthand\u201d for two other commands: <code>git fetch<\/code> then <code>git merge<\/code>.<\/p>\n\n\n\n<p>Here are a few ways this command is commonly used:<\/p>\n\n\n\n<p><code>git pull [remote]<\/code><br>Fetch a specific remote repo and merge it with the local you&#8217;re working on.<\/p>\n\n\n\n<p><code>git pull --no-commit [remote]<\/code><br>This command still fetches the remote repo, but does not automatically merge it.<\/p>\n\n\n\n<p>Since pull is such a core Git command, there are <i>tons<\/i> of ways to use it. This guide to <a href=\"https:\/\/www.gitkraken.com\/learn\/git\/commands\" target=\"_blank\" rel=\"noopener\">Git Branch Commands<\/a> offers even more examples and some fresh combos you can try.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git fetch<\/code><\/h3>\n\n\n\n<p><code>git fetch<\/code> as a standalone command downloads commits from remote repos into local repos. It gives you the chance to see and modify code from other devs.<\/p>\n\n\n\n<p>Let\u2019s try out this command:<\/p>\n\n\n\n<p><code>git fetch origin<\/code><br>Downloads a copy of the origin remote repository and saves it locally. Nothing is changed or merged, unlike what <code>git pull<\/code> does by default.<\/p>\n\n\n\n<p><code>git fetch --all<\/code><br>Grab data from <i>all<\/i> remote repos (origin included).<\/p>\n\n\n\n<p><code>git fetch --shallow-exclude=[revision]<\/code><br>Excludes commits from a specific branch or tag.<\/p>\n\n\n\n\n\n<div class=\"glossary-term\">\n\t<a\n\t\tclass=\"glossary-term__above-title\"\n\t\thref=\"\"\n\t\ttarget=\"_blank\"\n\t\trel=\"noopener noreferrer\"\n\t>\n\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 640 512\"><path d=\"M320 32c-8.1 0-16.1 1.4-23.7 4.1L15.8 137.4C6.3 140.9 0 149.9 0 160s6.3 19.1 15.8 22.6l57.9 20.9C57.3 229.3 48 259.8 48 291.9v28.1c0 28.4-10.8 57.7-22.3 80.8c-6.5 13-13.9 25.8-22.5 37.6C0 442.7-.9 448.3 .9 453.4s6 8.9 11.2 10.2l64 16c4.2 1.1 8.7 .3 12.4-2s6.3-6.1 7.1-10.4c8.6-42.8 4.3-81.2-2.1-108.7C90.3 344.3 86 329.8 80 316.5V291.9c0-30.2 10.2-58.7 27.9-81.5c12.9-15.5 29.6-28 49.2-35.7l157-61.7c8.2-3.2 17.5 .8 20.7 9s-.8 17.5-9 20.7l-157 61.7c-12.4 4.9-23.3 12.4-32.2 21.6l159.6 57.6c7.6 2.7 15.6 4.1 23.7 4.1s16.1-1.4 23.7-4.1L624.2 182.6c9.5-3.4 15.8-12.5 15.8-22.6s-6.3-19.1-15.8-22.6L343.7 36.1C336.1 33.4 328.1 32 320 32zM128 408c0 35.3 86 72 192 72s192-36.7 192-72L496.7 262.6 354.5 314c-11.1 4-22.8 6-34.5 6s-23.5-2-34.5-6L143.3 262.6 128 408z\"\/><\/svg>\n\t\t<span><\/span>\n\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 384 512\"><path d=\"M342.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L274.7 256 105.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z\"\/><\/svg>\n\t<\/a>\n    <h3>Tag<\/h3>\n    <p>A WordPress tag is a default taxonomy that enables you to categorize your posts. Readers can then click on a post\u2019s tag to view similar articles with the same tag.<\/p>\n            <a\n            href=\"https:\/\/www.dreamhost.com\/glossary\/wordpress\/tag\/\"\n                        class=\"btn btn--white-outline btn--sm btn--round\"\n                                    target=\"_blank\"\n            rel=\"noopener noreferrer\"\n            >\n                            Read More                    <\/a>\n\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git merge<\/code><\/h3>\n\n\n\n<p>The <code>git merge<\/code> command combines branches (most often two, but can be more) to create a singular history. Git will highlight conflicts that arise in the merge to be fixed.<\/p>\n\n\n\n<p>Options for this command include:<\/p>\n\n\n\n<p><code>git merge [branch name]<\/code><br>Use this to merge changes from the named branch into the branch you\u2019re using.<\/p>\n\n\n\n<p><code>git merge --abort<\/code><br>Stop the merge and restore the project to its pre-merge state. This command perfectly illustrates how Git helps maintain older code versions to protect project progress.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git add<\/code><\/h3>\n\n\n\n<p><code>git add<\/code> is the command to use when you\u2019re ready to \u201csave\u201d a copy of your work. It\u2019s very often used in conjunction with the next command \u2014&nbsp;<code>git commit<\/code> \u2014 as this adds (aka \u201ccommits\u201d) what\u2019s been saved to the project&#8217;s running history.<\/p>\n\n\n\n<p>Here are some ways you can specify what to save (or \u201cstage\u201d) with this command:<\/p>\n\n\n\n<p><code>git add [file]<\/code><br>This tees up all the changes you\u2019ve made to a specific file so it can be included in the next commit.<\/p>\n\n\n\n<p><code>git add [directory]<\/code><br>Similar to above, this cues changes to a specific directory so it&#8217;s ready for the commit.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git commit<\/code><\/h3>\n\n\n\n<p><code>git commit<\/code> is the second command in the trifecta of making and tracking a change in Git.<\/p>\n\n\n\n<p>This command basically says to store any changes that were made with the <code>git add<\/code> command. Not to make the changes to the main code, just to hold them safely.<\/p>\n\n\n\n<p>Some options for using this command include:<\/p>\n\n\n\n<p><code>git commit --amend<\/code><br>Modifies the last commit instead of creating a whole new one.<\/p>\n\n\n\n<p><code>git commit -m [your message here]<\/code><br>Annotate your commit with a message, which goes inside the brackets.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git push<\/code><\/h3>\n\n\n\n<p><code>git push<\/code> completes the collaboration cycle in Git. It sends any committed changes from local to remote repositories. From here, other developers on the project can start working with the updates. It\u2019s the opposite of the fetch command.<\/p>\n\n\n\n<p>Here\u2019s how to use it:<\/p>\n\n\n\n<p><code>git push [remote] [branch]<\/code><br>Push a specified branch, its commits, and any attached objects. Creates a new local branch in target remote repo.<\/p>\n\n\n\n<p><code>git push [remote] --all<\/code><br>Push <i>all<\/i> local branches to a specific remote repo.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git branch<\/code><\/h3>\n\n\n\n<p>Create, edit, and remove branches in git with the <code>git branch<\/code> command.<\/p>\n\n\n\n<p>Use the branch command in these ways:<\/p>\n\n\n\n<p><code>git branch [branch]<\/code><br>This creates a new branch, which you can name by replacing the word in brackets.<\/p>\n\n\n\n<p><code>git branch -c<\/code><br>This command copies a Git branch.<\/p>\n\n\n\n<p><code>git push [remote repo] --delete [ branch name]<\/code><br>Delete a remote Git branch, named in the last set of brackets.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git checkout<\/code><\/h3>\n\n\n\n<p>Use the <code>git checkout<\/code> command to navigate among the branches inside the repo you\u2019re working in.<\/p>\n\n\n\n<p><code>git checkout [branch name]<\/code><br>Switch to a different Git branch, named within the brackets.<\/p>\n\n\n\n<p><code>git checkout -b [new-branch]<\/code><br>Simultaneously create a new branch and navigate to it. This shortcut combines <code>git branch<\/code> and <code>git checkout [new branch]<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git remote<\/code><\/h3>\n\n\n\n<p>With the <code>git remote<\/code> command you can see, create, and delete remote connections, \u201cbookmarks\u201d in a way, to other repos. This can help you reference repos in your code without having to go find them and use their full, sometimes inconvenient names.<\/p>\n\n\n\n<p>Try these remote commands:<\/p>\n\n\n\n<p><code>git remote add [alias] [URL]<\/code><br>Add a remote repository by specifying its link and giving it an alias.<\/p>\n\n\n\n<p><code>git remote -v<\/code><br>Get a list of remote connections, and include the URLs of each.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git revert<\/code><\/h3>\n\n\n\n<p><code>git revert<\/code> undoes changes by creating a new commit that inverses the changes, as specified.<\/p>\n\n\n\n<p>One way to (carefully!) use <code>git revert<\/code> is:<\/p>\n\n\n\n<p><code>git revert [commit ID]<\/code><br>This will only revert changes associated with the specific commit that\u2019s been identified.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git reset<\/code><\/h3>\n\n\n\n<p><code>git reset<\/code> is a more risky and potentially permanent command for undoing commits.<\/p>\n\n\n\n<p>This command should only be used in local or private repos to prevent the chances of interrupting anyone who\u2019s coding in a remote, public repo. Since it can \u201corphan\u201d commits that may then get deleted in Git\u2019s routine maintenance, there\u2019s a real chance this command can erase someone\u2019s hard work.<\/p>\n\n\n\n<p>This is a complex command that should be used with discretion, so before trying it for the first time we strongly recommend reading this <a href=\"https:\/\/www.atlassian.com\/git\/tutorials\/undoing-changes\/git-reset\" target=\"_blank\" rel=\"noopener\">Git Reset<\/a> guide from Bitbucket.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git status<\/code><\/h3>\n\n\n\n<p><code>git status<\/code> provides insights into your working directory (this is where every stored historical version lives) and staging area (kind of like the \u201cunder construction\u201d area between the directory and repository). With this command you can see where your files stand.<\/p>\n\n\n\n<p>There\u2019s one primary way to use this command:<\/p>\n\n\n\n<p><code>git status<\/code><br>See a list of staged, unstaged, and untracked files.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git clone<\/code><\/h3>\n\n\n\n<p>Use <code>git clone<\/code> to create a copy of an existing repository. This is useful for creating a duplicate of a repo in which you can play around without damaging anything that\u2019s live to the public.<\/p>\n\n\n\n<p>Here are some options for using this command:<\/p>\n\n\n\n<p><code>git clone [repository URL] --branch [branch name]<\/code><br>Clone the linked repository, then jump right to a specific branch within it.<\/p>\n\n\n\n<p><code>git clone [repo] [directory]<\/code><br>Clone a specific repository into a specific directory folder on your local machine.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git init<\/code><\/h3>\n\n\n\n<p>Use the <code>git init<\/code> command to create a new Git repository as a .git subdirectory in your current working directory. It\u2019s different from <code>git clone<\/code> as it can create a new repository instead of only copying an existing one.<\/p>\n\n\n\n<p>The most common applications of this command include:<\/p>\n\n\n\n<p><code>git init<\/code><br>Where it all starts, this transforms your current directory into a Git repository.<\/p>\n\n\n\n<p><code>git init [directory]<\/code><br>With this, you can turn a specific directory into a Git repository.<\/p>\n\n\n\n<p><code>git init --bare<\/code><br>This generates a new bare repository, from which commits can\u2019t be made. This creates a helpful staging ground for collaboration.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git rebase<\/code><\/h3>\n\n\n\n<p><code>git rebase<\/code> has history rewriting powers that help keep your commits neat and clean.<\/p>\n\n\n\n<p>It\u2019s an option when you need to integrate updates into the main branch with a fast-forward merge that shows a linear history.<\/p>\n\n\n\n<p><code>git rebase [target branch name]<\/code><br>Rebase your checked out branch onto a specific target branch.<\/p>\n\n\n\n<p><code>git rebase [target branch name] -i<\/code><br>Initiate an <i>interactive<\/i> rebase from your checked out branch onto a different target branch.<\/p>\n\n\n\n<p>This is another complex command that shouldn\u2019t be used in a public repo as it may remove important elements of the project history. To learn more about how both the standard and interactive versions of this command work, we again recommend Bitbucket and their <a href=\"https:\/\/www.atlassian.com\/git\/tutorials\/rewriting-history\/git-rebase\" target=\"_blank\" rel=\"noopener\">git rebase<\/a> guide.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git diff<\/code><\/h3>\n\n\n\n<p>\u201cDiffing\u201d is the practice of displaying the variations between two data sets.<\/p>\n\n\n\n<p>The <code>git diff<\/code> command shows variances between Git data sources such as comments, files, etc.<\/p>\n\n\n\n<p>Options for using this command include:<\/p>\n\n\n\n<p><code>git diff --staged<\/code><br>Shows the difference between what\u2019s staged but isn\u2019t yet committed.<\/p>\n\n\n\n<p><code>git diff [commit ID 1] [commit ID 2]<\/code><br>This command compares changes between two different commits.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git tag<\/code><\/h3>\n\n\n\n<p>The <code>git tag<\/code> command points at a time in Git history, usually a version release. Tags don\u2019t change like branches do.<\/p>\n\n\n\n<p><code>git tag [tag name]<\/code><br>Use this to name a tag and capture the state of the repo at the time.<\/p>\n\n\n\n<p><code>git tag -d [tag name]<\/code><br>Want to remove that tag? Run this command.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git rm<\/code><\/h3>\n\n\n\n<p>The <code>git rm<\/code> command removes files from both staging and the working directory.<\/p>\n\n\n\n<p>Here are a few ways to try out <code>git rm<\/code>:<\/p>\n\n\n\n<p><code>git rm [file]<\/code><br>This is the basic code to get a file ready for deletion in the next commit.<\/p>\n\n\n\n<p><code>git rm --cached<\/code><br>This removes a file from the staging area, but keeps it in the working directory so you still have a local copy in case you need it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git log<\/code><\/h3>\n\n\n\n<p><code>git log<\/code> provides a, well, <i>log<\/i> of all the commits in the history of a repository.<\/p>\n\n\n\n<p>Ready to try it out? Here we go:<\/p>\n\n\n\n<p><code>git log [SHA]<\/code><br>A Secure Hash Algorithm (SHA) is a unique identifier for each commit. Use this command to display a certain commit as well as every other commit made previously.<\/p>\n\n\n\n<p><code>git log --stat<\/code><br>The command displays which files were changed with each commit, number of lines added\/removed, and number of files and lines edited.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><code>git show<\/code><\/h3>\n\n\n\n<p>This <code>git show<\/code> command line provides details on different Git objects like trees, tags, and commits.<\/p>\n\n\n\n<p>Here are a few ways to exercise this command:<\/p>\n\n\n\n<p><code>git show [SHA]<\/code><br>The simplest of <code>git show<\/code> commands, Use the SHA that we just learned about above to show the details of any object.<\/p>\n\n\n\n<p><code>git show [SHA]:path\/to\/file<\/code><br>This will show a specific version of a file you&#8217;re seeking when you include its SHA.<\/p>\n\n\n\n<p>Still learning how to use Git, have any questions about the above commands, or just itching to dive into even more variations that you can use to manipulate your code in <i>thousands<\/i> of ways?<\/p>\n\n\n\n<p>We have to shout out the <a href=\"https:\/\/www.atlassian.com\/git\/tutorials\" target=\"_blank\" rel=\"noopener\">Git tutorials<\/a> from Bitbucket as a great, deep, and interconnected resource that can take you most places you want to go with Git.<\/p>\n\n\n\n<p>And go you should. After all, open-source,&nbsp;and the Git tech that powers most of it,&nbsp;is the future of business.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1600\" height=\"950\" data-src=\"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/GitHub_Stat.jpg\" alt=\"Over 90% of Fortune 100 companies already use GitHub\" class=\"wp-image-41966 lazyload\" data-srcset=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub_Stat.jpg.webp 1600w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/GitHub_Stat-300x178.jpg 300w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/GitHub_Stat-1024x608.jpg 1024w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/GitHub_Stat-768x456.jpg 768w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/GitHub_Stat-1536x912.jpg 1536w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub_Stat-600x356.jpg.webp 600w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub_Stat-1200x713.jpg.webp 1200w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub_Stat-730x433.jpg.webp 730w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub_Stat-1460x867.jpg.webp 1460w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub_Stat-784x466.jpg.webp 784w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub_Stat-1568x931.jpg.webp 1568w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/GitHub_Stat-877x521.jpg.webp 877w\" data-sizes=\"(max-width: 1600px) 100vw, 1600px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1600px; --smush-placeholder-aspect-ratio: 1600\/950;\" \/><\/figure>\n\n\n\n<h2 id=\"reallife\" class=\"wp-block-heading\">Commands In Real Life: How To Develop On WordPress Using Git + GitHub<\/h2>\n\n\n\n<p>We just threw a ton of possibly new terms and tricks at you.<\/p>\n\n\n\n<p>If you aren\u2019t deep into Git, it can be hard to see how these can all come together to work in a real-life scenario.<\/p>\n\n\n\n<p>So we\u2019ll top things off with a walkthrough of how to use Git and GitHub to set yourself up to develop on a WordPress website.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Install WordPress.org<\/h3>\n\n\n\n<p>First up, the WordPress part.<\/p>\n\n\n\n<p>You\u2019re going to <a href=\"https:\/\/www.dreamhost.com\/blog\/guide-to-manual-wp-install\/\" target=\"_blank\" rel=\"noopener\">install a WordPress.org<\/a> instance (learn the <a href=\"https:\/\/www.dreamhost.com\/blog\/wordpress-differences-beginners-guide\/\" target=\"_blank\" rel=\"noopener\">difference between WordPress.com &amp; WordPress.org<\/a> if you\u2019re not familiar) and create a local staging environment on your computer.<\/p>\n\n\n\n<p>If you don\u2019t already have a great process for this, we like <a href=\"https:\/\/localwp.com\/\" target=\"_blank\" rel=\"noopener\">Local\u2019s<\/a> WP-specific dev tool.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Install Git<\/h3>\n\n\n\n<p>And just like that, it\u2019s time for the Git part.<\/p>\n\n\n\n<p>Install Git if you haven\u2019t already. Find the latest version on the <a href=\"https:\/\/git-scm.com\/\" target=\"_blank\" rel=\"noopener\">Git website<\/a>.<\/p>\n\n\n\n<p>Many Mac and Linux machines already have Git installed. Check yours by opening your command line interface (like Terminal on Mac or Git Bash on Windows) and entering the first command of this tutorial:<\/p>\n\n\n\n<p><code>git --version<\/code><\/p>\n\n\n\n<p>If Git is there, you\u2019ll get a version number back. If not, this <a href=\"https:\/\/github.com\/git-guides\/install-git\" target=\"_blank\" rel=\"noopener\">Git installation<\/a> guide will get you on your way.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Create A Local Repo With Git<\/h3>\n\n\n\n<p>Now, we\u2019ll create your local Git repo.<\/p>\n\n\n\n<p>Access your WordPress theme\u2019s folder (this example includes Twenty Twenty-One) using this command:<\/p>\n\n\n\n<p><code>cd\/Users\/[you]\/Documents\/Websites\/[website]\/wp-content\/themes\/twentytwentyone<\/code><\/p>\n\n\n\n<p>Replace [you] and [website] with your own folder names. Then, initialize this directory as a repository with this command:<\/p>\n\n\n\n<p><code>git init<\/code><\/p>\n\n\n\n<p>To add every file in the folder to the index, type in:<\/p>\n\n\n\n<p><code>git add<\/code><\/p>\n\n\n\n<p>Commit your changes with a notation that will keep your history organized with this command:<\/p>\n\n\n\n<p><code>git commit -m \u201cfirst commit\"<\/code><\/p>\n\n\n\n<p>Your local repo is configured!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Create A Remote Repo With GitHub<\/h3>\n\n\n\n<p>At this point, you want to create a <a href=\"https:\/\/github.com\/\" target=\"_blank\" rel=\"noopener\">GitHub<\/a> account if you don\u2019t already have one.<\/p>\n\n\n\n<p>Once created and signed in, you can create a remote repository from your GitHub dashboard.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1600\" height=\"900\" data-src=\"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/Create-A-Remote-Repo-With-GitHub.jpg\" alt=\"Create A Remote Repo With GitHub\" class=\"wp-image-41967 lazyload\" data-srcset=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Create-A-Remote-Repo-With-GitHub.jpg.webp 1600w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/Create-A-Remote-Repo-With-GitHub-300x169.jpg 300w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/Create-A-Remote-Repo-With-GitHub-1024x576.jpg 1024w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/Create-A-Remote-Repo-With-GitHub-768x432.jpg 768w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/10\/Create-A-Remote-Repo-With-GitHub-1536x864.jpg 1536w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Create-A-Remote-Repo-With-GitHub-600x338.jpg.webp 600w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Create-A-Remote-Repo-With-GitHub-1200x675.jpg.webp 1200w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Create-A-Remote-Repo-With-GitHub-730x411.jpg.webp 730w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Create-A-Remote-Repo-With-GitHub-1460x821.jpg.webp 1460w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Create-A-Remote-Repo-With-GitHub-784x441.jpg.webp 784w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Create-A-Remote-Repo-With-GitHub-1568x882.jpg.webp 1568w, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/smush-webp\/2023\/10\/Create-A-Remote-Repo-With-GitHub-877x493.jpg.webp 877w\" data-sizes=\"(max-width: 1600px) 100vw, 1600px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1600px; --smush-placeholder-aspect-ratio: 1600\/900;\" \/><\/figure>\n\n\n\n<p>When you\u2019re finished following the steps to set up your new project, it\u2019s time to get your WordPress theme into your new remote repo in GitHub.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Add WordPress Project To GitHub (Learning To Push)<\/h3>\n\n\n\n<p>Use these commands in Git to push your WordPress theme into GitHub:<\/p>\n\n\n\n<p><code>git remote add origin [repo URL]<\/code><\/p>\n\n\n\n<p><code>git push -u origin master<\/code><\/p>\n\n\n\n<p>Replace the URL in brackets with a link to the repository you just set up in GitHub.<\/p>\n\n\n\n<p>Next, you\u2019ll be asked to enter your GitHub username and password.<\/p>\n\n\n\n<p>Once those are in, files committed to your local repo thus far will be pushed to your GitHub repo.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. Optional: Fetch (AKA Pull) Updates<\/h3>\n\n\n\n<p>Now that you\u2019ve pushed changes from your local repo to the remote repo on GitHub, the last thing to learn is how to pull changes so you can do the reverse \u2014 add updates from the remote repo to your local one.<\/p>\n\n\n\n<p>Of course, if you\u2019re working independently on a coding project, you won\u2019t need to do this step. However, it\u2019s helpful to know as it immediately becomes necessary once you\u2019re collaborating with a team who are all making and pushing updates.<\/p>\n\n\n\n<p>So, we\u2019re going to pull updates into local using the fetch command:<\/p>\n\n\n\n<p><code>git fetch [URL]<\/code><\/p>\n\n\n\n<p>Don\u2019t forget to replace [URL] with the link to the repository from which you\u2019re pulling.<\/p>\n\n\n\n<p>With that, changes are pulled from GitHub and copied to your local, so both repos are the same. You\u2019re synced and ready to work on the latest version of the project!<\/p>\n\n\n\n<p>Still need a hand with Git?<\/p>\n\n\n\n<p>For a much more detailed walkthrough of the above process, check out our full guide on <a href=\"https:\/\/www.dreamhost.com\/blog\/how-to-use-wp-with-github\/\" target=\"_blank\" rel=\"noopener\">How to Use GitHub for WordPress Development<\/a>.<\/p>\n\n\n\n<p>Or, better yet, <b>engage our <\/b><a href=\"https:\/\/www.dreamhost.com\/pro-services\/development\/\" target=\"_blank\" rel=\"noopener\"><b>development experts<\/b><\/a><b> at DreamHost<\/b>.<\/p>\n\n\n\n<p>Let us handle one-off website tweaks to full-on website management, so your team can get back to the development and management work that moves your business <i>forward<\/i>.<\/p>\n\n\n\n\n\n<div\n\tclass=\"article-cta-shared article-cta-small\"\n>\n    <div class=\"tr-img-wrap-outer jsLoading\"><img decoding=\"async\" class=\"js-img-lazy \" src=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/themes\/blog2018\/assets\/img\/lazy-loading-transparent.webp\" data-srcset=\"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/themes\/blog2018\/assets\/img\/article-small-ad-cta-placeholder.webp 1x, https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/themes\/blog2018\/assets\/img\/article-small-ad-cta-placeholder-x2.webp 2x\"  alt=\"Ad background image\" \/><\/div>\n\n\n\n\n  <div class=\"content-btm\">\n    <h2\n      class=\"h2--md\"\n    >\n      You Dream It, We Code It\n    <\/h2>\n    <p\n      class=\"p--md\"\n    >\n      Tap into 20+ years of coding expertise when you opt for our Web Development service. Just let us know what you want for your site \u2014 we take it from there.\n    <\/p>\n\n            <a\n            href=\"https:\/\/www.dreamhost.com\/pro-services\/development\/\"\n                        class=\"btn btn--white-outline btn--sm btn--round\"\n                                    target=\"_blank\"\n            rel=\"noopener noreferrer\"\n            >\n                            Learn More                    <\/a>\n\n  <\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Anyone who uses Git,&nbsp;or has even seen it for that matter,&nbsp;knows there are a lot of terms and modifiers to keep up with. And keep up, you must, as it\u2019s become the standard in version control for tech products today. But instead of just expecting you to keep it all in your head, we put [&hellip;]<\/p>\n","protected":false},"author":1058,"featured_media":41958,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_yoast_wpseo_metadesc":"Learn the basics of Git and GitHub, 21 Git commands every developer should know, and how to use Git commands in a real-life software scenario.","toc_headlines":"[[\"introduction\",\"Quick Debrief: Understanding Git, GitHub, &amp; Version Control\"],[\"mostused\",\"21 Of The Most-Used Git Commands You Should Know\"],[\"reallife\",\"Commands In Real Life: How To Develop On WordPress Using Git + GitHub\"]]","hide_toc":false,"footnotes":""},"categories":[13129,696],"tags":[],"class_list":["post-41957","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developer-central","category-wordpress"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.3 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Ultimate List of Git Commands - DreamHost<\/title>\n<meta name=\"description\" content=\"Learn the basics of Git and GitHub, 21 Git commands every developer should know, and how to use Git commands in a real-life software scenario.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"21 Must-Know GitHub Commands\" \/>\n<meta property=\"og:description\" content=\"Master your GitHub projects with 21 essential commands. Learn how to clone, commit, merge, and more to make the most of your Git experience.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/\" \/>\n<meta property=\"og:site_name\" content=\"DreamHost Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DreamHost\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-03T14:00:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-21T23:11:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2023\/09\/List-of-Git-Commands-SOCIAL-Image.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ian Hernandez\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"21 Must-Know GitHub Commands\" \/>\n<meta name=\"twitter:description\" content=\"Master your GitHub projects with 21 essential commands. Learn how to clone, commit, merge, and more to make the most of your Git experience.\" \/>\n<meta name=\"twitter:creator\" content=\"@dreamhost\" \/>\n<meta name=\"twitter:site\" content=\"@dreamhost\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ian Hernandez\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Ultimate List of Git Commands - DreamHost","description":"Learn the basics of Git and GitHub, 21 Git commands every developer should know, and how to use Git commands in a real-life software scenario.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/","og_locale":"en_US","og_type":"article","og_title":"21 Must-Know GitHub Commands","og_description":"Master your GitHub projects with 21 essential commands. Learn how to clone, commit, merge, and more to make the most of your Git experience.","og_url":"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/","og_site_name":"DreamHost Blog","article_publisher":"https:\/\/www.facebook.com\/DreamHost\/","article_published_time":"2023-10-03T14:00:45+00:00","article_modified_time":"2025-05-21T23:11:16+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.dreamhost.com\/blog\/wp-content\/uploads\/2023\/09\/List-of-Git-Commands-SOCIAL-Image.jpg","type":"image\/jpeg"}],"author":"Ian Hernandez","twitter_card":"summary_large_image","twitter_title":"21 Must-Know GitHub Commands","twitter_description":"Master your GitHub projects with 21 essential commands. Learn how to clone, commit, merge, and more to make the most of your Git experience.","twitter_creator":"@dreamhost","twitter_site":"@dreamhost","twitter_misc":{"Written by":"Ian Hernandez","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/#article","isPartOf":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/"},"author":{"name":"Ian Hernandez","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#\/schema\/person\/220faf2464d5ae08e41cf5f3b28fdc96"},"headline":"Git Commands: 21 Must-Know Options","datePublished":"2023-10-03T14:00:45+00:00","dateModified":"2025-05-21T23:11:16+00:00","mainEntityOfPage":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/"},"wordCount":3049,"publisher":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/#organization"},"image":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/#primaryimage"},"thumbnailUrl":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/09\/List-of-Git-Commands-HERO-Image.jpg","articleSection":["Developer Central","WordPress"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/","url":"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/","name":"Ultimate List of Git Commands - DreamHost","isPartOf":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/#primaryimage"},"image":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/#primaryimage"},"thumbnailUrl":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/09\/List-of-Git-Commands-HERO-Image.jpg","datePublished":"2023-10-03T14:00:45+00:00","dateModified":"2025-05-21T23:11:16+00:00","description":"Learn the basics of Git and GitHub, 21 Git commands every developer should know, and how to use Git commands in a real-life software scenario.","breadcrumb":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/#primaryimage","url":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/09\/List-of-Git-Commands-HERO-Image.jpg","contentUrl":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2023\/09\/List-of-Git-Commands-HERO-Image.jpg","width":1460,"height":1095,"caption":"List of Git Commands HERO Image"},{"@type":"BreadcrumbList","@id":"https:\/\/www-dev.dreamhost.com\/blog\/git-commands\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dhblog.dream.press\/blog\/"},{"@type":"ListItem","position":2,"name":"Git Commands: 21 Must-Know Options"}]},{"@type":"WebSite","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#website","url":"https:\/\/www-dev.dreamhost.com\/blog\/","name":"DreamHost Blog","description":"","publisher":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www-dev.dreamhost.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#organization","name":"DreamHost","url":"https:\/\/www-dev.dreamhost.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/dhblog.dream.press\/blog\/wp-content\/uploads\/2019\/01\/dh_logo-blue-2.png","contentUrl":"https:\/\/dhblog.dream.press\/blog\/wp-content\/uploads\/2019\/01\/dh_logo-blue-2.png","width":1200,"height":168,"caption":"DreamHost"},"image":{"@id":"https:\/\/www-dev.dreamhost.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DreamHost\/","https:\/\/x.com\/dreamhost","https:\/\/www.instagram.com\/dreamhost\/","https:\/\/www.linkedin.com\/company\/dreamhost\/","https:\/\/www.youtube.com\/user\/dreamhostusa"]},{"@type":"Person","@id":"https:\/\/www-dev.dreamhost.com\/blog\/#\/schema\/person\/220faf2464d5ae08e41cf5f3b28fdc96","name":"Ian Hernandez","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/04\/ian-hernandez-dreamhost-150x150.png","url":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/04\/ian-hernandez-dreamhost-150x150.png","contentUrl":"https:\/\/www-dev.dreamhost.com\/blog\/wp-content\/uploads\/2022\/04\/ian-hernandez-dreamhost-150x150.png","caption":"Ian Hernandez"},"description":"Ian is a Product Designer based in Los Angeles, California. He is responsible for driving brand and product design at DreamHost, developing and maintaining our internal design system, and writing frontend code when he can. In his free time, he enjoys walking his dog, learning history, and discovering new music online and irl. Connect with him on LinkedIn: https:\/\/www.linkedin.com\/in\/ianhernandez23\/","url":"https:\/\/www-dev.dreamhost.com\/blog\/author\/ianh\/"}]}},"lang":"en","translations":{"en":41957,"es":42016,"pt":52959,"de":52962,"ru":54994,"uk":55059,"pl":55110,"it":67812,"fr":69210,"nl":69230},"pll_sync_post":[],"_links":{"self":[{"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/posts\/41957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/users\/1058"}],"replies":[{"embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/comments?post=41957"}],"version-history":[{"count":9,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/posts\/41957\/revisions"}],"predecessor-version":[{"id":61439,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/posts\/41957\/revisions\/61439"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/media\/41958"}],"wp:attachment":[{"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/media?parent=41957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/categories?post=41957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www-dev.dreamhost.com\/blog\/wp-json\/wp\/v2\/tags?post=41957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}