Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
GIT: Branching and Merging
Rating: 4.4 out of 5(1,286 ratings)
7,682 students

GIT: Branching and Merging

Learn the basics of working with branches and resolving merge conflicts using GIT and GitHub
Created byBrian Gorman
Last updated 5/2024
English

What you'll learn

  • Use the Bash Shell Terminal to interact with GIT
  • Understand Git Branching
  • Understand Git Merging
  • Set a default Merge Tool.

Course content

9 sections59 lectures4h 44m total length
  • Welcome & Info about this course2:41

    I'm excited that you are interested in learning more about GIT.  To make sure this course is the course you are looking for, I want to just go over a few things about what we'll cover in our course.

    First, however, I'd like to personally welcome you to this awesome journey you are about to go on.  GIT is such a powerful (and popular) source control tool.  Distributed source control has a lot of benefits that are unable to be offered by a traditional centralized source control system, and GIT is probably the leader in this area (since it's not the only distributed source control system, I can't officially claim it is the leader ;)).  One of the greatest benefits is the fact that creating branches is very inexpensive, and can allow for great flexibility when working with your code (or any files you have in a GIT repository).

    So how do you know if this course is for you?  The best way to determine is to talk about what this course will offer you: a chance to go from a beginner to an intermediate level with GIT.  Here at Udemy, I have a free course that is a five-day challenge for GIT.  That is the basic beginner flow, and is a way you could get your feet wet.  If you've already done that, great!  If you haven't done it but don't need the basic level: also great!  

    In order to get to the next level with GIT, this course will help you learn how to work with the BASH terminal to run the actual GIT commands to do the following:

    • Create a branch locally
    • Push a branch to a remote repository at GitHub
    • Checkout branches
    • Delete branches
    • Merge changes from one branch to another
    • Merge changes at GitHub using a pull request
    • Create and work with a team
    • Resolve merge conflicts
    • Set a default editor (VSCode - or your choice)
    • Set a default difftool (VSCode - or your choice)
    • Set a default mergetool (VSCode - or your choice)
    • and more

    We'll take a direct look at and use the following commands in our course

    • git add
    • git commit
    • git push
    • git fetch
    • git pull
    • git merge
    • git branch
    • git checkout
    • git status
    • git log
    • git show
    • git diff

    Additionally, we'll have heavy interaction at GitHub and learn about what it takes to perform common team activities, as well as how we can create branches and merge pull requests at GitHub.

    Finally, by the end of the course, you'll be in a position to call yourself proficient with GIT, as long as you understand that this course will NOT take you all the way to becoming a GIT master.

    I'm looking forward to working with you and can't wait to hear about your journey along the way.

    Let's get started!

  • What this course won't cover1:34

    I like to start every course with a "What this course won't do" because I feel this information is just as important, if not more important for your decision to take this course as a "what this course 'will' do" is.

    So, here are few things that this course will not do:

    • This course will not make you a better programmer
    • This course will not teach programming at all
    • This course will not make you a GIT Master or GIT Expert
    • This course will not teach you about advanced GIT commands that rewrite history, or other advanced commands
    • This course will not teach you how to rescue your repository when stuff goes horribly wrong
    • This course will not help you get a job directly [but if you do get a job, you better know what's in this course, so there is that]

    The main idea of this course is to get you to a point where you are comfortable working with branches and merging changes across branches to work as a proficient team member using GIT and interacting with GitHub.

    Additionally, I hope that taking this ground-up approach will position you for greater success and understanding, while overcoming fear.

    Now that you know what this course will and won't do, let's get started!

  • Get an account at GitHub3:19

    In order to work with a remote repository, we need somewhere to host it.  GitHub is the ideal choice for this course because it is one of the most popular places to store code, both privately and publicly.  There are other choices available for sure, such as BitBucket, GitLab, and Azure DevOps (among others).  If you're familiar with using one of those, then by all means keep using it!  All of the major providers will have the ability to do everything that we are covering in this course (it just may look slightly different at the other providers).  

    Speaking of looking differently, before diving in, note that this video was recorded a couple of years ago.  I've created so many accounts at GitHub at this point that I don't think it's reasonable to do another account to make a video.  For that reason, I'm trusting that you will have the skills to make your account at GitHub using your email and a password.  

    A couple of things are different in this video from how they are now.  For example, GitHub no longer requires a subscription to have private repositories!  So you will see a section where I talk about that in the video - just know that you do not need to sign up to pay for any subscription at GitHub and you will still be able to do free repositories and all the other things you would want to do in this course and beyond without paying for anything.

    I would also recommend enabling Multi-factor authentication at GitHub using a generator like the GitHub authenticator, the Microsoft authenticator, or any other authenticator (it gives you a code on your phone after you add the account).

    In this video, we walk through setting up an account at GitHub.  In some ways I feel silly even putting a video like this out there.  Hopefully getting an account at a website is not something you will struggle with.  So if you've already got an account at GitHub and/or you know how to do this, you wouldn't really need to watch this video. 

    In other ways, there are people who like to see everything from the ground up.  For those of you who are like me, this walk through will be nice background noise while you work through getting an account set up at GitHub.

    In the end, to move forward with this course, the main goal here is that you have a working account at GitHub where you can create Remote repositories.  

    One final note: In this video I mention getting an account at BitBucket as something else we might do in this course.  To be clear, this course will not have any videos or information about using BitBucket.  However, you are perfectly able to use BitBucket if you choose as everything we do here can be done against BitBucket.    The same thing goes for GitLab, Azure DevOps, or another provider.  However, this course will only show interactions with GitHub.

  • Setup a Repo at GitHub3:56

    In this video, we take a look at getting our first repository setup at GitHub.  If this is not new to you, then you may feel free to just skip over this lecture. If you've never done this before, then I hope you will find the information in this video useful.  

    When working with our files/code we need to have a remote repository so that the data is not just stored on our machine.  Could we get by without a central location? Of course, but only if we are the only one using the files, and we'd be losing out on a lot of useful things that a remote repository offers.  For example, putting our code on a remote repository gives us the chance to restore to any machine, at any time.  Not only that, be we can easily make changes on one or more machines at different times or the same time, and then we can make sure that no changes are lost using branching and merging.

    The REMOTE repository will be the centralized location, and we'll clone and/or create repositories to work with on our LOCAL machines.  We'll set up our LOCAL repositories so that they track to REMOTE.  This is how we'll be able to move changes from REMOTE to LOCAL and LOCAL to REMOTE.  

    For our course, we'll need a central repository stored at GitHub, and this video shows how we go about getting it setup.  If you can't quite follow along the first time, don't worry: The activity that follows will get us setup for our course.

  • Get An Account at GitHub, and Setup a new Repo
  • Get VSCode for use as an editor, a diff tool, and a merge tool7:26

    We'll be doing a lot of work from the command line for our course.  The tools that come along with GIT are able to do whatever we need to do, but they are not the most intuitive tools to use - especially for non Unix users.  

    Fortunately, there are options available and GIT is very extensible - meaning that we can choose to to a bit of customization and be able to work with a tool that is more convenient for us.  

    While there are many solutions available, the solution I've chosen to use is VSCode for our course.  This is a platform agnostic tool, and it is very powerful, and, best of all, it is completely free.

    If, for some reason, you don't want to use VSCode, you are welcome to use another tool.  You will be on your own for getting it configured, however.

    In this video, we walk through getting VSCode installed on our machines.  

  • Get Visual Studio Code on your machine
  • Get GIT on your machine [Windows]7:09

    This video shows how to install GIT on your machine. If your version is newer, that is just fine.  You should select the newest (latest) version that is available at the time you are taking this course.  

    Note that this video is taken from a series I made to get a developer box set up.  At the end, the video mentions a next part about validating GIT. Part two is not included here because that is just checking your version, creating a repo, setting credentials, and using add and commit, and we do that through the rest of this course, so you don't need that video as all of it is covered in the next few videos.

    Topics Covered
    - GIT Download (git-scm dot com/downloads) [Windows]
    - Install location
    - Options for installation
        - Open in Git Bash
        - Use Visual Studio Code as Git's default editor
        - Override to `main` as the default branch
        - Git from the command line
        - Use bundled OpenSSH
        - Use the OpenSSL library
        - Checkout Windows-style, commit Unix-style line endings
        - Use default terminal
        - Fast-Forward or merge (default)
        - GIT Credential Manager
        - No experimental support

  • Get GIT on your machine [Ubuntu Linux]2:04

    In this video, we go about getting GIT setup on our machines.  This is the "Ubuntu Linux" version.  Without getting GIT on our machine, we won't be able to run the commands and work with the repositories as shown in the rest of the course.

  • Get GIT on your machine [MAC]2:25

    Without getting GIT on our machine, we won't be able to run the commands and work with the repositories as shown in the rest of the course.  Unfortunately, at the moment I have no access to a MAC to create the installation video.  Please use the provided link in the article to go to the official download page, and follow any instructions/prompts to get GIT on your MAC setup.

  • Get GIT on your machine
  • Setup VSCode as the default editor5:13

    Although GIT BASH comes with VIM built-in, hitting "i" to insert and "escape colon w q" to write and quit gets pretty old, pretty fast, especially for a non-unix guy like me.

    Therefore, we're going to use VSCode as an additional tool to help us when working with GIT on our machines.  This is a powerful and free tool, and is only one option of many that are available to you.  If you can't stand Microsoft or want to go a different route, you are welcome to do so, but just know that you are on your own for getting the exact syntax for setting up a tool other than VSCode (stack overflow would most likely have the answers you need to use your favorite tool).

    In this video, we create the global settings necessary to set our default editor.

    NOTE: If you installed VSCode prior to GIT, then you were likely given the choice to use VSCode as the default editor.  When you do that, you have already completed this step!

  • Set VSCode as the default editor
  • Setting your GIT configuration [default credentials]0:11

    If you are on a new machine or have never used GIT, you have to set your config to include your user name and email for your signature on all GIT commits. This should be done with the email you use for GitHub (or whatever service you are using).

  • I already have a project, how do I add it to a REMOTE Repository9:31

    Perhaps you already have some projects and you want to get them into source control.  If that is the case, then you will want to see how this is done.

    After this video, there is an activity that lets you take the default web that I'm using in this course and put it out on your own repository at GitHub.

    Additionally, you could just go to my repository directly [https://github.com/majorguidancesolutions/defaultweb_activity] and either

    • download the code directly
    • or clone the repository locally, then delete the .git folder and start from scratch
    • or fork the repository to your own account at GitHub

    To be honest, you really don't need any of this.  Also, if you have your own code, you can just use that.  What we need to get through this course is nothing more than a repository where we can store any text file and just work against it.  So if you want to just have one text file in a folder and create a repository and push it out to GitHub, you would be able to do everything we're doing in this course with that minimal implementation.

    In the video I mention that I would ask you to clone/fork the repo in a later video.  I'm actually not going to do that - it's up to you what you want to do and you can use this repo or one of your own, it's completely up to you.

  • Get an existing project into a new LOCAL repository and then publish to a REMOTE
  • Updating GIT From the command line3:55

    It may be the case that you have not worked with GIT for some time, that you aren't automatically updating, and/or you just need to get the latest version manually.  In this video, you'll see how to quickly run a command to update GIT from the command line.

Requirements

  • No, we'll do some stuff from the ground up. However, you might want to do my FREE Git 5 day challenge first to get your feet wet and make sure this is for you.
  • If you can't work with a computer, this isn't for you.

Description

This course is an introduction and overview of branching and merging with GIT.  By the time you complete this course, you'll be able to understand what it means to create branches locally or at a remote repository.  You'll have a great command of keeping your branches up-to-date and cleaning up both your local and remote repository.

By the end of the course, you'll be in command of working with teams at GitHub and using Pull Requests to validate changes by multiple developers.  You'll know how to make sure you get their changes as well, and finally you'll be able to resolve merge conflicts locally and at GitHub.

Why should you learn the command line when tools are available like Visual Studio, E-Git, GitHub for desktops, and many others?  Because all tools are just wrappers around the commands.  If you use the tools you should be fine, but what about when things go wrong?  Who will help you then?  Knowing the commands makes it EASY to go to using any IDE with Git.  Not knowing the commands could be the difference between doing something wrong or just not knowing what to do at all.

Here are some of the commands we'll be interacting with during this course [and you'll get good at using them -- however -- we won't MASTER any of them, but --after this course -- you'll be able to take the study deeper on your own from here for any of these commands!].

  1. git add
  2. git commit
  3. git push
  4. git pull
  5. git fetch
  6. git status
  7. git log
  8. git show
  9. git checkout
  10. git diff
  11. git difftool
  12. git merge
  13. git mergetool
  14. git config

Additionally, this course will show you how to setup a default tool for editing, git difftool, and git mergetool [VSCode in this course, but you could use Perforce P4Merge or another tool if you want]. 

Who this course is for:

  • Anyone that wants to learn the commands for working with GIT to branch and merge.
  • Anyone that wants to learn about interactions with GitHub including creating a branch and working with a pull request.
  • Junior developers
  • Anyone switching to GIT