Brendan Enrick

Daily Software Development

Deleting a Remote Git Branch

Another bit of git command line that a lot of people struggle to remember is the syntax to delete a remote branch. If you read my post from a couple of days ago, I mentioned a couple of things about deleting git branches. That’s how you delete them locally. If you want to push that deletion up to the remote repository as well, you need to take one additional step.

The command I use to delete remote branches is this:

git push origin :my-branch-name

It’s that “:” that tells it to delete the branch. Yes, it may seem confusing, but there is a reason for it. I’ll explain below for those who are interested in learning more.

Here is a slightly easier syntax, but I don’t like typing the additional characters.

git push origin --delete my-branch-name

Feel free to use this syntax, it’s newer, but you most likely have support for it. It’s been out for years now.

Here is the reason (other than its being shorter) that I like the first syntax better.

If you want to push our a git branch, you use this command:

git push origin my-branch-name

If you wanted it to have a different name remotely than it has locally, you would do this:

git push origin my-local-name:my-remote-name

Which means that if you wanted to push “nothing” over the remote branch with that name you would do this:

git push origin :my-remote-name

Notice how the command is pushing empty over that branch, which is then interpreted as a “delete” by git. That’s how I make sense of it, plus this is a neat little bit of info about the command.

I hope this helps people adopt and use git more easily. If you’re new to git or GitHub, I recommend that you check out my Pluralsight course, GitHub for Windows Developers. The course takes an easy-to-follow approach to getting you set up using Git, GitHub, and GitHub for Windows.

Speaking at CodeMash 2015

I am very grateful to be speaking at my 6th CodeMash. I’ve again been selected to present a precompiler on Software Craftsmanship (a topic I am very passionate about). I hope that everyone can attend my workshops. I’ve got two of them again, so I’ll be spending a full day working with software craftsman coding. We’ll be focusing as always on practicing, pairing, testing, and applying all of these effectively. We’ll work through ways you can use practice to learn new concepts and patterns to improve your skills at building great software.

SpeakerSelection

Once again, Steve Smith and I will be presenting these Precompiler workshops together, so you’re sure to have a blast!

Our sessions are usually held back-to-back, so that you can attend the beginner session in the morning and follow it up with the intermediate session in the afternoon. Last year, our afternoon session had to have extra chairs and tables brought in for all of the extra people who showed up. My goal every year is to put on a workshop that will be the highpoint of your CodeMash! Join us for some great coding, learning, and practicing of your software skills.

If you’re in the Northeast Ohio area and want to learn more about software craftsmanship, you should check out HudsonSC. Our October meeting has been scheduled already. We meet on the third Wednesday of every month in Hudson, Ohio.

Deleting Git Branches Carefully

I noticed someone recently using a “hard delete” in the git command line recently. I commented on it being brave, but it turns out that he didn’t realize there was a different way to delete a branch in git. In case anyone else is wondering the difference, here is a quick tip on it.

In the git command line, you can use the “-D” parameter to delete a branch. It looks like this:

git branch –D my-branch-name

This will delete the branch regardless of whether it’s been merged back in. This can be dangerous, since you may lose changes that you’ve not yet merged elsewhere.

If you want to be more careful with your branch deletion, you should use a lowercase “d” with the “-d” or “—delete” parameter. That would look like this:

git branch –d my-branch-name

This will delete the branch only if you have merged the branch up already. This means that the branch’s changes should have been saved in the parent branch already, so it’s safe to delete. If you try this when it hasn’t been merged, you’ll received a message telling you that the branch was not deleted for this reason.

If you want to see the branches that still need to have their changes merged, you can do that using the following command:

git branch --no-merged

If you want to see the branches that can safely be deleted, because their changes have already been merged upstream, you can use this command:

git branch --merged

I hope you found these quick tips useful while you’re using git. If you’re new to git or GitHub, I recommend that you check out my Pluralsight course, GitHub for Windows Developers. The course takes an easy-to-follow approach to getting you set up using Git, GitHub, and GitHub for Windows.

A Git Branch Changes Nothing

I'm serious. If you create a new branch in git, you didn't really do much of anything. All you did was make a pointer. There is no copying of the files. No additional changesets. When you checkout the branch you just created, you still didn't really do anything. It just changes which branch you’re on. The files don’t change at all. That's because git does not need to change the source code at all in order to deal with this new branch.

When you start changing the code, however, you'll be adding new commits that are in that branch. The branch itself isn't really a thing though, since git effectively just makes a linked list of your changesets.

NetworkGraph

In the example shown here, notice that the blue line for “feature-xyz” does not have a dot until it’s first commit. That is because the branch starts, and it’s just a link pointing nowhere. Once there is a commit, there is some significance, but the branch itself is nothing. Git is primarily just a tree made of these links. This simple example illustrates some basic branching and merging.

I hope this little bit of info about git makes using it easier. If you want to learn more about using GitHub, please check out my Pluralsight course on GitHub.

Drag Drop Repo - GitHub Tips 5

I’ve got a Pluralsight course about using GitHub that went live on Tuesday, so I thought I would post a few quick tips to help anyone using GitHub or GitHub for Windows and also promote my course.

There are a ton of ways to get a repository into GitHub for Windows to use it to manage your repository. I go over all of these in my Pluralsight course, but one of the neatest ways to add a repository is to just drag and drop the folder or the page.

You literally just need to go to the folder in explorer and drag the folder into GitHub for Windows.

DragFolderToCreate

Once you’ve dragged the folder in, it will bring up this “Create” context menu if it’s not already a repository. This will also call “git init” on the folder, so it becomes a repository.

AfterDragging

Once it’s done, you’ll have a repository. It will commit an initial .gitattributes and .gitignore file for you.

AfterDragAndCreated

If you already have a repository on GitHub, you can drag the URL into GitHub for Windows.

DragDropBrowserUrl

Once you drag it in, GitHub for Windows may want to know where to store the local copy. Just choose a location for it.

DragDropBrowserUrlChooseFolder

After it is done cloning the repository, you’ll have a local, connected copy.

DragDropBrowserUrlCloned

I hope these little tricks make it easier for you to set up repositories with GitHub for Windows, and if you want to learn more about GitHub, check out my Pluralsight course.

Open Shell Here - GitHub Tips 4

I’ve got a Pluralsight course about using GitHub that went live on Tuesday, so I thought I would post a few quick tips to help anyone using GitHub or GitHub for Windows and also promote my course.

When you need to use the command line, it’s nice to open it right in your repository instead of having to “cd” your way there. When you’re in GitHub for Windows, you can use the Tools context menu to “Open Shell” like this:

OpenGitShellContextMenu

Once open, you’re in a git shell in your repository with context-aware information to help you complete your task.

GitShellOpenInRepo

I hope this quick tip is useful for you, and if you’d like to learn more about GitHub and GitHub for Windows, please check out my Pluralsight course.

Two Factor Auth - GitHub Tips 3

I’ve got a Pluralsight course about using GitHub that went live yesterday, so I thought I would post a few quick tips to help anyone using GitHub or GitHub for Windows and also promote my course.

One of the main concerns that I hear from businesses about hosting their code off-site is security. While nothing can ever be “completely secure”, you can help yourself a little bit by enabling two factor authentication in GitHub. It uses most two factor authentication apps, so you can set up any device as the second key.

Once you’ve got it set up, GitHub for Windows will even prompt you for that auth token after you type your password. Annoying to have an extra step? Yes. More secure? Yes.

GitHubTwoFactorAuth

I hope that tip helps someone keep their GitHub account safer, and if you want to learn more about GitHub, please check out my Pluralsight course.

Descriptive Icons - GitHub Tips 2

I’ve got a Pluralsight course about using GitHub that went live today, so I thought I would post a few quick tips to help anyone using GitHub or GitHub for Windows and also promote my course.

When you’re running in GitHub or GitHub for Windows, you’ll see some icons that are near the repository name. These tell you a bit about the repository. They can indicate that a repository is a GitHub repository, non-GitHub repository, or a fork of a GitHub repository. They’ll be here when you’re running GitHub for Windows.

HighlightGitHubIcons

This icon indicates a GitHub repository:

GitHubIcon

This icon indicates a forked GitHub repository:

ForkedIcon

This icon indicates a repository that is either local-only or connected to a different remote (not GitHub):

LocalOrOtherRemoteIcon

I hope you find this quick tip useful. If you want to learn more about GitHub and GitHub for Windows, please check out my Pluralsight course!

Enter To Commit - GitHub Tips 1

I’ve got a Pluralsight course about using GitHub that will be going live this Tuesday, so I thought I would post a few quick tips to help anyone using GitHub or GitHub for Windows and also promote my course.

I thought I would start out these posts with a very simple time saver. When you’re typing your commit message, you can just click enter to commit your changes.

Click Enter To Commit

If you’re including additional information in a description, clicking enter will just give you a new line like so.

 EnterNewLineDescription

I hope knowing this will keep you from having to move your hands from your keyboard, and if you want to learn more about GitHub, check out my GitHub course! This tip is not mentioned in my course, so you’ll need to watch it to learn more.

My New Development Setup

I’ve been working as a developer for quite a few years now, and I’ve had a number of different setups and development rigs. Laptops, desktops, pairing stations, etc. have all been my tools over the years. They all get the job done, some pieces work better than others though. Here is a look at what I am using now.

Desktop Overall

When I started working from home, I wanted to make sure that I bought a simple desk to be distinct from my non-work desk. I bought this desk, since it was relatively inexpensive and I wasn’t sure how long I would be working from home. I am of course hoping to grow a team in my area. So far, the desk and set up have been working well.

Yoga2Pro

This is not an intentional selfie. It’s just a picture of the Lenovo Yoga 2 Pro that I’ve been using for development. I was a bit concerned at first, since I am used to using development desktop computers. It’s worked well for me so far. I am not sure if I will need more than the 256GB SSD, but I’ve got plenty of space even with all of my development tools installed. I’ve not had any performance issues, but I am not working on projects with long build times.

Probably the coolest thing that I was issued when joining Clear Measure, was my docking station. I am used to placing my laptop on a docking station using a special docking port on the laptop bottom.

DynaDock

This docking station was super easy to set up and runs both of my monitors, keyboard, mouse, headset, Internet, and I just have to plug in 1 USB cable when I set the laptop down. It’s called a Dynadock, and is a bit more expensive than I would like. It works though! I can even plug in speakers, though I don’t use any. Headsets work better for calls than speakers, so I use these.

HeadsetStation

This is the cable to recharge my headset, and it nicely coils around this station with the wireless dongle plugging into the top.

Logitech-G930-Wireless-Headset

This is my Logitech G930 headset that I’ve been using for all of my video calls. It works great, fits comfortably and has very clear audio for me and everyone listening to me. I’ve had to unmute a couple of times and it will turn off automatically if you’re not using it for a while. I’ve run into that a few times with James Shaw on the call. He gets a good laugh about it. The headset is super comfortable, so I’ve got no complaints.

MouseAndPad

I like a high DPI Logitech G400 mouse, so I can quickly move the cursor while barely moving my mouse. This mouse is adjustable, so I keep it as high as possible. I’ve got others with these types of features, but this one is more comfortable and remembers the high DPI setting. On my others, I have to turn up the DPI setting after booting my computer.

You may also notice my highly stylish Pluralsight mouse pad. I’ve got a course that will be coming out soon.

StirTrekFlashDrive

One of many reasons I am glad to live in Ohio is that I am able to make it to Stir Trek every year. It’s a great annual conference in Columbus. It takes place in a movie theater, and is wrapped up by a movie. I have a bunch of these USB keys from them, and I keep one on my desk for quick, sneakernet transfers.

Moleskine-Pen-Notepad

I don’t know about you, but some things just need to be written on paper. I’m not a tablet and stylus user, so I grab this fancy Lake Quincy Media pen and write quick notes on this pad of paper or on my Moleskine notebook if it’s something more permanent.

AspAllianceCoaster

Speaking of swag that I have around, I’ve got this nice ASP Alliance coaster that I use. I’m a former ASP Alliance author, editor, and developer. I haven’t written articles for them in years, but I do have some nice swag from my time working there.

WindowAirConditioning

The last thing I want to point out about my setup is this window AC unit that I have in place to regulate the temperature in my office. Yes, I have central air conditioning in my house, but I often keep my door closed. My cat is a bit of a trouble maker, so I only occasionally allow him in. My south facing windows also keep the room warmer than the rest of the house with me, computer, and nowhere for the air to go. I also love keeping it quite cool while I work.