Skip to content

A beginner-friendly repository to learn Git branches and GitHub branching strategies.

License

Notifications You must be signed in to change notification settings

IIIT-Delhi/Git-Branching-Guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Git Branching Guide

Overview:

A beginner-friendly repository to learn Git branches and GitHub branching strategies. This project provides step-by-step instructions, code examples, and best practices for working with branches. Whether you're new to version control or looking to enhance your branching skills, this guide will help you navigate through the world of Git branches and collaboration on GitHub.

Git Branches:

1. Install Git:

If you haven't installed Git on your machine, you can download and install it from git-scm.com.

2. Initialize a Git Repository:

Open a terminal and navigate to the directory where you want to create your project. Run the following commands:

git init

3. Create a Branch:

To create a new branch, use the following command:

git branch 'branch_name'

Make sure to add your brannch name.

4. Switch to a Branch:

To switch to the newly created branch, use:

git checkout 'branch_name'

Make sure to add your brannch name.

Alternatively, you can use a single command to create and switch to a new branch:

git checkout -b 'branch_name'

Make sure to add your brannch name.

5. Make Changes:

Make changes to your project files while on the branch.

6. Commit Changes:

After making changes, commit them to the branch:

git add .
git commit -m "Your commit message here"
git push origin 'branch_name'

Make sure to add your commit message and brannch name.

7. Merge Branches:

Once you're done with changes on a branch, you can merge it back into the main branch (usually main or master):

git checkout main
git merge 'branch_name'

Make sure to add your branch name.

Additional Commands

  1. To view all Git branches:

    git branch
  2. To delete a Git branch:

    git branch --delete 'branch_name'

GitHub:

1. Create a GitHub Account:

If you don't have one, create a GitHub account at GitHub.

2. Create a New Repository:

On GitHub, click the "+" in the top right corner and select "New Repository."
Follow the instructions to create a new repository.

3. Push Code to GitHub:

After creating a repository, connect your local repository to the GitHub repository:

git remote add origin 'https://github.com/your-username/your-repository' .
git branch -M main
git push -u origin main

Make sure to add your username and your repository name.

4. Push Branches:

If you want to push branches other than main, use:

git push origin 'branch_name'

Make sure to add your branch name.

License

This project is licensed under the MIT License.

About

A beginner-friendly repository to learn Git branches and GitHub branching strategies.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages