Git and GitHub – Types of branch (Part-12)

Local and Remote Branches in Git

Local Branch

A local branch is a branch that exists in your local Git repository. You create and manage local branches on your machine, and they are used to track your work and changes.

  • Creating a Local Branch:
git checkout -b my-feature-branch
  • This command creates a new branch called my-feature-branch and switches to it.
  • Listing Local Branches:
git branch

This command lists all the branches in your local repository.

Remote Branch

A remote branch is a branch that exists on a remote repository, such as GitHub, GitLab, or Bitbucket. Remote branches are used to share your work with others and collaborate on a project.

  • Fetching Remote Branches:
git fetch
  • This command updates your local copy of the remote branches without modifying your local branches.
  • Listing Remote Branches:
git branch -r
  • This command lists all the remote branches that you have fetched.
  • Tracking Remote Branches:
git checkout --track origin/my-feature-branch

This command creates a local branch that tracks the remote branch origin/my-feature-branch.

Related Posts

Git and GitHub – GitHub Overview (Part-15)

1. Github Description: 2. Org (Organization) Description: Example: 3. Team Description: Example: 4. Auth (Authentication) Description: Examples: OAuth Authentication: Personal Access Tokens: SSH Key Authentication: 5. Action…

Read More

Git and GitHub – Git Log Explanation (Part-14)

Git Log Explanation Explanation of Each Part 1. Commit Hash 2. References (Branches and Tags) 3. Commit Message Simplified Breakdown of Each Line Summary The git log…

Read More

Git and GitHub – Merge and Pull (Part-13)

Merge and Pull in Git Merge Merge is a command used to combine the changes from one branch into another. It is typically used to integrate changes…

Read More

Git and GitHub – Git Undoing, Conflict Resolution, Cherry Picking, Stash (Part-11)

Undoing changes in Git can be approached in several ways, depending on what you need to achieve. Here, we’ll cover the most common scenarios and commands for…

Read More

Git and GitHub – Understanding Git Concepts (Part-10)

Understanding Git Concepts 1. Git Branching and Merging Branching allows you to create a separate line of development. It’s useful for working on different features or fixes…

Read More

Git and GitHub – How to push/pull and clone files between Local machine and GitHub (Part-9)

Git and GitHub: Step-by-Step Guide Let’s explore how to interact with Git and GitHub, focusing on pushing, pulling, and cloning files between your local machine and GitHub….

Read More
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x