Giter VIP home page Giter VIP logo

lab-git-branching's Introduction

Objective

  • Creating branches
  • Merging changes
  • Managing branches in Git

Prerequisites

  • A GitHub account.
  • Git installed on your local machine.

Steps

1. Fork the Repository

  • From this GitHub repository.
  • Click on "Fork" above to create a copy in your GitHub account.

2. Clone the Forked Repository

Clone the forked repository to your local machine:

git clone [URL of your forked repository]

Replace [URL of your forked repository] with the actual URL of your fork.

3. Create and Work on Branch A

Navigate to your repository:

cd [repository name]

Check the current branch using the command below (should be main):

git branch

Create and switch to branch A:

git checkout -b branch-a

Confirm you are on branch A:

git branch

Add a text file to this repo named feature1.txt

touch feature1.txt

Open the text file and add "feature 1" to the feature1.txt file. Example command below:

open feature1.txt

Add the text "feature 1" to the file, save and close the editor.

Go back to your terminal and check the status of your git:

git status

Add and commit the change:

git add feature1.txt
git commit -m "Add feature 1"

4. Create and Work on Branch B

Switch to the main branch and check the current branch:

git checkout main
git branch
ls and enter

Create and switch to branch B:

git checkout -b branch-b
git branch

Add a text file to the current branch, branch-b, of this repo named feature1.txt

touch feature1.txt

Manually open the text file and add "feature 2":

open feature2.txt

Add the text "feature 2" to the file, save and close the editor.

Add and commit the change:

git add feature2.txt
git commit -m "Add feature 2"

5. Merge Branch B into Branch A

Switch to branch A and merge branch B into it:

git checkout branch-a
git merge branch-b

Resolve any conflicts if they arise and commit the changes.

6. Merge Branch A into Main

Switch to the main branch:

git checkout main
git merge branch-a

7. Delete Feature Branches

Delete branches A and B locally:

git branch -d branch-a
git branch -d branch-b

8. Push Main Branch and Create a Pull Request

Push the main branch to your forked repository:

git push origin main

9. Title Pull Request

On GitHub, navigate to your forked repository and create a pull request to the original repository. Title your PR "Merge branch-b into branch-a: Add both files."

lab-git-branching's People

Contributors

castonpursuit avatar davidcruzesk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.