From Worcester State University Computer Science Department Wiki
Jump to: navigation, search

Git Cheat Sheet from GitHub

Git Resources

  • [2] -Jeremiah Atiswini
  • [3]-Jeremiah Atiswini
  • [4] -Jeremiah Atiswini

Review by Jeremiah atiswini: Git is a system that allows you to track all push and pull changes you have made to a remote resource. Depending on what type of Git service you are working on (GitLab, GitHub or Bitbucket), git have the same platform though they are designed to address a specific need. For instance, gitLab is designed for internal management of organizational repositories; this is usually created by organizations to execute projects that are not going to be displayed in public and it is only the authorized persons that have access to it. GitHub in the other hand is an open source account that is openly available to everyone when you push your work to GitHub unless otherwise, you have a protected paid account. Even though Git have same platform across all the difference account, the command you will use basically depends on the service you are using. It is also quite simple to transfer codes or files from one service to another. In conclusion, haven exposure to all these service gives you the ability to manage git projects effectively without any hindrance.

Review by Ricky Phan: This blog written by Michael Herman was very informative on the basics of using git commands. Each of his cut and paste examples is great for viewers to visualize what's happening with each git command he uses. Afterwards he gives an explanation of what is going on with each different command. It almost similar to the TryGit Tutorial, except Herman breaks it down in three sections, intializing, staging, and maintaining. I like it how he breaks it down into these sections because it gives me a transparent overview of how and when each command should be used when you initialize, stage, or maintain files in your repository. Git commands such as "git init" and "git clone" are used most often for the initialization step. Git commands such as "git add" and "git status" are used mainly for the staging step. Git commands such as "git add .", "git commit", "git push", "git pull", and "git log" are used for the maintaining step. Overall, it was a great blog to read for understanding the basic git commands!

Reviewed by Quoc Phan: This Git resource is the best! It's great for anyone new to git or anyone who wants to learn more. It has five section beginner, getting started, collaborating, migrating to Git and advanced tips. The beginner section explains what is version control and Git in short and easy to understand format. It also show you how to get started with Git by having easy to follow directions to install Git into your PC. I love how the website supplies you with a cheat sheet that you can download which I found very useful later on because it very hard to memorize all those commands. The Getting Started section help me set up my repository without any problems. The Collaborating section was very informative. Migrating to Git was easy to understand and The Advanced Tips section great for experience users who want to learn something new. I give this Git Resource a 10 out 10.

Review by Kristi Pina: One of the clearest, easiest and quickest guide that I have ever read is Dudler’s guide. It explains the function of the most important and most useful command in Git, using visual designs and diagrams, that make the information more understandable for the reader. What makes this source more important is not just the introduction of each command, but also the explanation how to perform an operation using a set of commands. The explanation of the “workflow” is very concise, and the hints at the bottom are very helpful for some additional information and knowledge about Git. Following with quick overview guide will never let you forget any simple thing in the version control process. In my opinion, it can be considered as the best refresher of Git in general. Moreover, it adds some additional links for everyone who need additional information and more resources.

Review by Sayan Moitra: Roger Dudler's guide to getting set up on github was one of the more enjoyable guides on the principles I've read. The webpage is formatted with nice colors and casual fonts that make it easy to read and don't feel overwhelming. In terms of the topics covered, Dudler walks through much of the same basics covered in the introductory material provided by GitHub personally, however what I enjoyed the most of his guide was the fact that he went into branching. Branching in VCS is very important however many introductory guides sometime stray away from it for fear of adding "unnecessary complications." However Dudler supplements the branching introduction with great pictures and diagrams in the format of the other parts of the guide. It makes it very easy to follow and learn. The additional links at the bottom create a nice starting point for any additional reading.

Review by Matt Foley:This is a guide for using the basic git commands. It is nothing fancy, and doesn’t cover very advanced topics, but it is concise and does a great job at showing how the use the most important git commands. I would recommend this guide to someone who has never used git before, but it would also serve as a good “refresher” course for someone who hasn’t used git in a while. The guide also focuses on the workflow of git, which I feel is a very important concept to understand in order to use git correctly. It discusses the use of branches, how to switch between them, and how to merge code. These are all important things to understand how to use not only to understand the purpose of git, but also to make sure you don’t ruin someone else’s work. You have to remember that more often than not, multiple will be using the same repository, so you have to be careful of what you are doing. Following this guide will help a lot in making sure you don’t mess up someone else’s work or your own work for that matter.

Review by Kwame Ofori : I was fortunate enough to discover git everyday during my search for proper git documentations. This link contained a useful minimum set of commands for everyday git usage. The information I found here was not only suitable for me but it seemed to have things that would benefit, developers, managers and pretty much any one wanting to know more about git and its usage. So throughout the documentation, there are about 20 git commands that are being used in real world scenarios. The information presented provided you with information and ways to use the particular git command that was being shown. I particular think this page is very informational because of the simplicity of the explanations and how well labeled each section is categorized. It makes it easy on the eye to read and understand what is going on. As it goes on, there are also numerous screenshots of expected outcomes and command results. You almost can’t get lost when following through this.

Review by Dennis Tran: Based on the topics I have read from the “Git basics- a general workflow” guide, I would say that this was a great read on the basic commands of git. This guide does not go over the more complicated discussions of git, but it is brief and can benefit in using git much easier. I would recommend this to those who need help with understanding the purpose of git and those who have questions in making sure that their work stays safe. This guide not only focuses on the main commands of git but also the workflow of git. The workflow of git I believe is an important concept to remember so that git is used in the correct way. It discusses topics such as managing the branches, merging codes, and shortcuts using aliases. These topics will help in making sure searching for commands is not troublesome and the work from yourself and others is not lost. By reading this guide, it will help in making such that git is simple to use and can be used as a good refresher of git in general.

Review by George Matthew: The Git Videos page offered by GitHub's On Demand Learning Resources website was a valuable resource for me to learn both the basics of using git and also how to do some of the more complex tasks in git. I sometimes get bored reading books or following tutorials but find that watching videos is often more engaging. I also find video tutorials to be easier to follow, as you can see the actions that lead to the desired result rather than simply reading and following text instructions, even if the text instructions are accompanied by screenshots. The tone of the videos is largely conversational, which I also prefer to the formal or authoritative tone that many tutorials use. Many of the videos provide visual representations of what they are attempting to accomplish with different units labeled and their functions explained not only in the audio of the video but also with text on the screen. The multimedia method of content delivery on the Git Videos page of GitHub's On Demand Learning Resources website was effective for my visual learning preferences, and I would recommend them for anyone with a similar learning style.

Review by Nathan Posterro: This article explains 30 different git CLI options that are not as well known as others. The first thing it talks about is how you can use -p to partially stage and unstage files in your git terminal. The article then goes on to talk about how you can spice up your git diffs by using git diff -w. This means that your git diffs will ignore all whitespace, and could make your terminal more appealing to look at while you are reading your git diffs. Another cool trick in the article is how you can fix mistakes on commits by using git commit --amend. This is especially useful in case you accidentally forget a file or put the wrong file in, and you didn’t realize it until after you committed your project. Instead of having to manually edit the files, then go through the process of git status and git add, you can just use git commit --amend and then you can make your fixes there.

Review by Erika Reinertson: This guide offers both an interactive portion in addition to the very in depth explanations of the fundamentals of git. I consider this guide to be extremely helpful for programmers just beginning to use git. From the very beginning this guide covers all of the basics including common commands and how to interact with the repository. The most interesting part of this guide, and how it specifically stood out to me, was that they offer a repository that's already set up where you can practice cloning, committing and pushing your work all by yourself. This allows all beginners to actually gain hands on experience on what it's like to interact with the repository in an environment where they essentially can't break anything. All in all, this guide was helpful in giving a great overview of how git works as a whole and how branching allows you to build in a better way.

Review by Ben Anderson: Git Videos On Demand Training is a great tool to help learn how to use git and in get a more depth look on how git works and cool features you can do in it as well. It goes in depth with most of the git commands you can use in git and have videos for each command which is really helpful for people that learn from being shown than just reading. They have videos on the fork command, Reset command which I just found out was a command, even talk about advanced git tricks for people that really want to master git, there is a lot of information here for anyone to learn a lot about git. If you don't want to learn the advanced parts first, they have a git basic video as well which will teach you what you need to get started with git. Git is an efficient way of sharing projects with classmates and other people that you want to view your work and these tutorials will help you use it. Common Git Commands - Learn How To Use Git Review by Urooj Haider: This is a relatively short yet informative guide to a few of the most commonly used git commands. It covers working with local as well as remote repositories. It also goes over advanced git commands and offers some other git resources for you to use for a review or to learn more about git. As you scroll down the page, there is first an explanation of the command and then the command is shown. The first time it is shown is for usage and the second time is a practice example to put the command into context. This website is a good way to review the commands incase you do not remember what they are. It is also a good reference to use while working with git. You must definitely know these commands in order to work with git otherwise it will be difficult to add files or push/pull files from the repositories. This website is a good way to review the git commands or learn them for the first time if you are a beginner working with git.

Review of git - the simple guide by Daniel Ryder: This is a straightforward guide that explains the basic and commonly used commands in git. It explains fundamentals such as creating a new repository, the git workflow, adding and committing, and branching. There is also a section for useful hints and links to other git resources. Overall I thought this guide was very good for what it intends to be, which is just a simple resource for people who are just starting out with git. It is a good post to look at when you need a refresher on git commands, as it is organized well and doesn't get bogged down by unnecessary information. This blog explains everything in a concise manner and would be a good first resource to look at for somebody who knows nothing about git. I will definitely come back to this guide if my memory fails me and I need to be reminded of the way git works.

Learning Git Branches Review by Rick Phillips - As we branch off into other avenues of git concepts, branching becomes an important part of the process. This interactive tutorial guides you through progressively harder levels of git commands.

The tutorial then extends to merging our new branches. It uses a desired DAG as the pattern to solve the particular task at hand. The next levels teach us about rebase and introduces the concept of the HEAD.

It offers tutorials up to and including on called spaghetti branches, which I have not tried. This is also a sandbox option that simply allows you to create a live DAG that grows while the user enters almost any valid git command. This is very useful for experimenting with the many commands and discovering how they connect together in the tree.

I found this tutorial very entertaining and helpful. It taught me a number of concepts that I had not yet fully wrapped my mind around. I think this would be very helpful for anyone who may be having trouble with Git. It is an open-source and actively maintained project.

Learn Git in 30 Minutes Review by Johnny To: This tutorial starts off the user from the very beginning, starting with the installation and configuration before going into creating a new repository. The dives into introducing the staging area within git and two important commands to remember by heart, the ‘git status’ and ‘git commit’. Eventually leading into the repository stage where the user would learn how to get their local changes into a repository hosting service like GitHub and learning the respective commands like ‘git push, pull, and clone’. Overall, this tutorial keeps it simple and sweet while occasionally creating scenarios to showcase a feature. Having clearly divided the tutorial into three important sections, it allows the user to take in the information and learn exactly where they are at on the ‘Git timeline’. Moving from local to server and then explaining the branches gives off an importance of how useful git is to a developer from a user standpoint. Lastly, they included an advanced section which showcases commands that are not needed during the learning stage of git but would give the user more freedom when they know it exists!

Review by Gulshan Kumar: This tutorial website explains the idea of git very well, especially the branching section. It divides git into a basic section and an advanced section while talking about remote repositories and branches in between. The basic section was done in a “beginners” to simply explain the push and pull commands of git along with the overall setup. I found the section on branches very interesting and understandable as they used simple sample code to show each step, making it easier to follow along. I always had trouble wrapping my head around the idea of merging branches and how they worked with the checkout command. The advanced section touches more on the “quality of life” commands that someone would use if they had experience with git and needed to do more complicated tasks like reverting files or fixing a commit. Overall, it was a great tutorial that simplified both the basics and the advanced, so you only get the information you need to know to correctly use the commands.

Review by Stephen Burke for “git: the simple guide” This guide starts off claiming to be useful to newcomers. I feel that the article useful for someone who has used git but doesn’t entirely understand what they are doing, or how git could work in a professional environment. The setup portion of the guide is as simple as a download link and the explanation of what the difference between the staging area and the head is a picture without any real analysis. For someone who has used git before, this may clear up some confusion about what exactly is going on throughout the process, but to newcomers, it’s likely just pictures. In terms of branches, I feel that the guide follows the same level of clarity. The commands given are useful but can be abstract to newcomers as well. I will give the writer credit for mentioning that one needs to push a new branch for it to become visible to others. As the guide progresses, the author explains more, making the guide more useful and understandable for all. If I was to give this guide an overall rating, I’d give it 3.5/5 for overall usefulness.

Review by Andy Pham (What is Git): This tutorial by Atlassian explains what Git is by talking about its performance, security, and flexibility as well as explaining by Git is the best choice for most software teams today. It improves performance by allowing developers to work on different versions of their project if necessary and seamlessly switch between them. All the objects in the Git repository are secured with a hashing algorithm called SHA1, protecting the code and the change history from being altered. Git is also flexible because it supports various kinds of nonlinear development workflows, is efficient in projects of any size, and its compatible with many existing systems. Overall the tutorial is useful in explaining why Git is so widely used while also making sure to include potential criticisms of Git, such as how it can be difficult for a newcomer to learn or how it doesn't have a central repository, and explaining why despite those criticisms, Git is still the best choice.

Review by Amir Adelinia: Being introduced to the Git environment can be somewhat overwhelming, in that there are numerous things you can do with it and the primary way to interact and manipulate your files is to type these commands through a command line. If you are new to Git or just interested with the basic fundamentals, the Git tutorial is a great place to learn the basics. It covers many of Git's functionalities such as committed and pushing files, as well as surveying for file modification and file errors. The thing that is great about this tutorial is that it guides you step by step through each procedure, providing a new command for each step of progression. In addition to that, it has a great explanation of the new command you are learning as well as an interactive web-based linux command terminal clone that you can type in the commands you are learning to verify that you are performing the correct operations. This tutorial is just an overall great and easy way to learn the basic functionalities of Git.

Review by Ryan Marcelonis: The Thing About Git is an entertaining and informative read. It was written in 2008, but the tips and tricks provided by Ryan Tomayko in this blog post will still serve to help you both understand Git/GitHub and optimize your Git/GitHub workflow. 'The thing about Git...', as Tomayko describes it, is that it takes a lot of the responsibility for the VCS away from the coder, allowing more of the focus to be directed toward code. He uses humor (and some vulgarity) to explain the problems with many VCS's and how Git/GitHub solves "The Tangled Working Copy Problem" - a 'big' problem in which a repository is modified from two different logical changes, leaving the master of the repository to work two changes apart into separate commits, somehow. He then provides tips on how to control your workflow by using the features of Git. I especially appreciated this portion of his post because he discusses working in the staging area of Git, where potential changes to a repository can be reviewed and modified in preparation for a merger with the main repository, which is an incredibly useful concept and utility.

Review by Ren Dutczak: [5] This tutorial was a bit lengthy, but gives specific detail on how to use Git. Each section contains information about the section, then shows an example of coding in Java, the command used in Git and the changes made in Java from the Git command. The life cycle section shows a diagram of the working process of Git, and the steps involved in the cycle. The manage branching section also has a diagram of how branching works. I found the tackling conflict section to be useful. This demonstrated what happens when two people tried to change the name of the same function to two different names at once. This will cause conflict in the merging. When Tom tried to pull Jerry’s branch on his computer to see the changes Jerry made, an error or conflict occurred. Tom was able to resolve the conflict by changing the command function, while still being able to see Jerry’s work. Once this was completed, Tom was able to change his work to match the name Jerry used and push his work back to Git. Overall the tutorial was user friendly and provided me with more specific information to utilize when accessing Git.

Review by Derek odame: Git is a type of a version control system(VCS). A version control system is the management of changes to documents, computer programs, large web sites, and other collections of information. Things that I learned from the website are the basic of git, branches, files and commit and benefits of Git. The basic of git, when every time one saves a work or a file, a commit is created by Git. A commit is a copy of all your work or files at a particular time period. I also noticed with Git, when a file has not changed from one commit to the next, Git uses the previously stored file. This type of functionality is different from other systems which some stores an initial version of the file or work and keep a record of channels over time. The branches, for my understanding about branches, there are part of everyday development process, and a pointer to a snapshot your changes. Files and commit, from the website, it says a Git file or files have three stages. The modified, staged, or committed. When the first modifies a file, then changes exist only in the working directory. Which are not yet part of a commit. You must first stage the changed files to include in the commit.

And finally, the benefit of Git. Git is a faster release, simultaneous developing , built-in integration, strong community support and it works very well in teams. Link :

Visualizing Git Concepts with D3 Review by Dominique Gould: This site’s sandbox approach to explaining Git makes it an excellent resource if you're a visual learner or if you learn by doing. The concepts of the git commands are briefly described, and you get to see how they function through interactive graphics which illustrate these concepts when you enter the commands in the terminal. It includes demonstrations of a few lesser-known commands like reset and rebase, with the helpful tip that you should never use these with commits you have already pushed. The difference between reset and revert is also emphasized: reset abandons more recent commits in the current branch when you move the head to a specific commit, while revert actually creates a new commit which undoes the changes in the commit you’re reverting. This is easy to grasp when shown in a visual format. Finally, the site offers some specific examples of things you might want to do which require multiple steps, and shows you how to achieve them through the git commands covered.

Difference between Fork and Clone


Opening Git Bash (Windows) in a specific folder

You can open Git Bash directly in the folder where you have your code, rather than using the cd and ls commands to navigate there.

  1. Open the folder where you have your project.
  2. Right-click and choose Git Bash
  3. The terminal window will open and you will already be in that folder.

Opening Terminal (Mac OS X) in a specific folder

You can open Terminal directly in the folder where you have your code, rather than using the cd and ls commands to navigate there. You will need use Go2Shell[6] which you can download for free from the App Store.

Once you download is, hold down Command + Option and drag the icon from Applications to the toolbar at the top of any Finder window. That will install a button that looks like: >_< When you want to use it:

  1. Open the folder with your code in Finder.
  2. Click the Go2Shell button.
  3. The terminal window will open and you will already be in that folder.

Example .gitignore file

A .gitignore file is a hidden file that specifies which files should not be committed as part of a Git repository. Usually you don't want to commit editor temporary files, compiled code, binaries, files containing passwords, etc. Adding these files to your .gitignore file will allow you to do things like git add . and not worry about accidentally committing those files.

File:Example.gitignore a useful example .gitignore file. Needs to be renamed to .gitignore to be used.