In Git Contributing, you learned how to delete a local branch. The command of -D is fairly straightforward. But what if you want to delete both the local and remote branches. Let’s build an alias.
Labs
Labs are hands-on coding projects that you build along with Tonya as she explains the code, concepts, and thought processes behind it. You can use the labs to further your code knowledge or to use right in your projects. Each lab ties into the Docx to ensure you have the information you need.
Each lab is designed to further your understanding and mastery of code. You learn more about how to think about its construction, quality, maintainability, programmatic and logical thought, and problem-solving. While you may be building a specific thing, Tonya presents the why of it to make it adaptable far beyond that specific implementation, thereby giving you the means to make it your own, in any context.
Prep for Complex Aliases
In order to build complex aliases, we want to open up the global .gitconfig file in the text editor that is wired to git. Then we’ll add some commenting to provide more context and details for our aliases. If you have not yet wired up your text editor to git, I highly….highly….highly recommend that you do so. Why? The main reason is for writing more detailed commit messages as well as doing rebasing too. Check out this lab for a Mac or Windows to wire yours up.
Git Productive
Let’s tame git. Let’s create a rich set of commands and shortcuts that make sense and are intuitive. Let’s build a set of scripts that are callable by a single command, such as `git uncommit` or `git rollback`, i.e. commands that wrap up repetitive tasks and automate them via a single command. In this hands-on coding lab, you’ll build a rich collection of these commands via git aliases and bash scripting to git you more productive.
Alias – Rollback to Last Commit
There are times when you are working on a change and then realize that you’ve gone in the wrong direction. At that point, you want to rollback your project back to the last commit, i.e. meaning you want to delete all of the changes and return your codebase back to the last commit. There are multiple steps to do this task as you need to delete everything in the staging and working areas. Let’s build an alias.
Alias – Commit All Changes from Working and Staging
Recall from Simply Git and Git Contributing how to commit changes. It is a two-step process of adding the changes from working into staging and then running git commit to move from staging into the storage (commit) area. Git gives you a way to combine those steps into one step. Typically, my workflow is: Commit the changes Pop open the editor Add my commit message Clear off the command line console View the status display View the log That’s a lot of steps to type over and over again. Let’s build a complex alias to give us one command git […]
Alias – Rename Current Branch
Imagine that you are working along on a change and then decide you need to rename the branch. Git gives you an option to move a branch to a new branch. But like most git commands, it’s not intuitive or rememberable. Let’s build an alias.
Alias – Create and Checkout New Branch
In Git Contributing, you learned how to create and checkout a new branch. I don’t know about you, but I find the command and option confusing. Let’s build an alias.
Alias – Reword (Fix) Last Commit Message Without Adding WIP
In the last episode, I warned you that fixing your last commit message when you have changes in the working or staging area is problematic. We can solve that problem by staging all of the changes before we fix the message and then restoring them after we’re done. Let’s build an alias.
Alias – Display Less Verbose Status
You know that you can use git status to view what is currently in the working and staging areas. In this episode, let’s make an alias for a less verbose status.
Alias – Unstage a Specific Change or All
What if you don’t want to unstage all of the changes; rather, you just want to unstage a specific change. Running git status tells you how to do it. But again the command and its options is not intuitive or rememberable. Let’s build a complex alias that: Processes the optional parameter when one is given with the command. Or sets a default value when one is not passed with the command.