Why GIT commands?

When you use GIT long enough, you begin to realize it is just easier to use GIT commands. Using a console is faster in every way because UI for some reason or another is laggy and sluggish. I don’t understand why, but it is. There are a lot of ways to do this, but in my opinion using GIT BASH is the easiest. You can do it via PowerShell and a variety of other ways – honestly they are all the same, the only thing that changes is what is available to you via the shell you are using. Things like how you can copy and paste your commands and colors. I like the way GIT BASH colors everything, not crazy about how copy and paste works – but it’s not a big deal.

Very basic GIT commands

There are a number of commands you will need that are fairly common to use, but easy to forget if you aren’t doing this 24/7. Here are some commands, I will probably be updating it as I go.

How to clone a repository

Honestly this depends on your target, if it is GitHub the following command is just fine. If you are working off of TFS you are better off using Visual Studio for the sake of simplicity.

How to delete a local branch

How to force delete a local branch when there are pending changes

Fetch from all remotes

Pull from all remotes

This will only pull for your current branch, don’t get confused with the “–all” portion.

List local branches

This shows you what local branches you have and puts an asterisk next to the branch you are currently pointing to.

List remote branches

Displays all of the remote branches with their commit Ids. Useful for when you don’t know what branches are available.

Switch branches

Switch to a local branch named master

Prune all local references of remote branches

This can clean up all mucky old references and removes branches that don’t exist anymore

Merge the remote master branch into your current local branch

How to create a new branch

Assuming you are on a branch you didn’t want to make changes on such as master
You can branch off of your current branch into a new branch along with your changes

Leave a Reply

Your email address will not be published. Required fields are marked *