From 9cf5b7e9ac290f09eafff99d20a8b271dfd48998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Necati=20=C3=96zmen?= Date: Wed, 27 Nov 2024 18:04:12 +0300 Subject: [PATCH] docs(blog): rename and update git switch article for snippets (#6525) --- .../{2024-07-16-git-switch.md => 2024-11-27-git-switch.md} | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) rename documentation/blog/{2024-07-16-git-switch.md => 2024-11-27-git-switch.md} (93%) diff --git a/documentation/blog/2024-07-16-git-switch.md b/documentation/blog/2024-11-27-git-switch.md similarity index 93% rename from documentation/blog/2024-07-16-git-switch.md rename to documentation/blog/2024-11-27-git-switch.md index a4d1bf70eaf0..4f4b686cf19c 100644 --- a/documentation/blog/2024-07-16-git-switch.md +++ b/documentation/blog/2024-11-27-git-switch.md @@ -8,7 +8,7 @@ image: https://refine.ams3.cdn.digitaloceanspaces.com/blog/2022-12-20-git-switch hide_table_of_contents: false --- -**This article was last updated on July 16, 2024, to add sections for Advanced Branch Management Techniques and Troubleshooting Branch Issues to Git switch post.** +**This article was last updated on November 27, 2024, to add to update switching explanations for Git switch post.** ## Introduction @@ -21,6 +21,8 @@ Note that the command `git checkout` is a multi-feature command which performs m • If it is a remote branch, it will create a tracking branch and will switch to it Let's go through some examples of switching branches through `git checkout`, and then we will touch upon the use of `git switch`. +Switching between branches is one of the basic Git operations when one needs to work with multiple features. To switch to an already existing branch, use `git checkout branch_name`. To create and switch to a new branch in one command, use `git checkout -b new_branch`. For remote branches, first fetch the branch using `git fetch --all`, then switch using `git checkout remote_branch_name`. With newer versions of Git, `git switch branch_name` is an easier way to switch to another branch. + Steps we'll cover: - [Using git checkout to switch branches](#using-git-checkout-to-switch-branches) @@ -173,6 +175,8 @@ This command gives you information about branches and their tracking status. ### Switching to a remote branch +Switching between branches is one of the basic Git operations when one needs to work with multiple features. To switch to an already existing branch, use git checkout branch_name. To create and switch to a new branch in one command, use git checkout -b new_branch. For remote branches, first fetch the branch using git fetch --all, then switch using git checkout remote_branch_name. With newer versions of Git, git switch branch_name is an easier way to switch to another branch. + To checkout a remote branch, you will need to fetch the contents of the branch using `git fetch –all` first. Then use the same command `git checkout RemoteBranchName` to switch to remote branch. You might have noticed that it is the same command used to switch to a local branch. If you want to switch to a remote branch that does not exist as local branch in your local working directory, you can simply execute `git switch remoteBranch`. When Git is unable to find this branch in your local repository, it will assume that you want to checkout the respective remote branch with the same name. It will then create a local branch with the same name. It will also set up a tracking relationship between your remote and local branch so that `git pull` and `git push` will work as intended.