Git Video Tutorial

Git Video TutorialOne of you guys asked me to make a Git video tutorial so I did.

Specifically I go over all the different types of version control. We look at the difference between modified, staged and committed. We then install and set everything up for Windows, OSX and Linux. I briefly go over using VIM and show how to set up other editors. Then I cover the commands init, add, commit, status, diff, rm, log and more. A cheat sheet follows the video below.

If you like videos like this, it helps to tell Google Plus with a click here

Other Git Video Tutorial Videos

Init, Add, Commit, Status, Diff, Rm, Log and Installation :

GitHub, Remote Repositories, Push, Pull, Remote, Fetch, Tagging, Aliases and Clone :

Branching, HEAD, Checkout, Rebasing, Reverting, Reset, Clean, Solving Merge Conflicts and Mergetool :

Generating SSH keys, how to set up multiple GitHub accounts on one computer and the Fork & Pull workflow :

Git Video Tutorial Cheat Sheet and Transcription


1. Mac :

2. Windows :

3. Linux : apt-get install git-core OR yum install git-core


1. Git is a version control tool that saves changes to groups of files so you can revert back if needed.

2. There are different types of version control tools

a. Local Version Control saves changes to files in a database

b. Centralized Version Control saves changes to a shared server

c. Distributed Version Control allows for easier sharing of files then LVC and also eliminates problems that could occur if access to the server is lost under a CVC system.

d. DVC clients have a complete backup of the files on their computer. If the server is lost the client just waits to regain contact and then uploads changes.

3. When you commit changes to files Git stores a reference of what the files look like at that moment. If a file isn't changed it isn't stored again.

4. Each client has a complete history of all changes stored locally. The client can also access all changes made to the files historically with a simple command. Also those files cannot be changed without Git knowing and changes are difficult to lose.

5. Files transition between 3 states with Git

a. Modified Files are files that have been recently changed

b. Staged Files have been marked to be saved

c. Committed Files are those that have been saved

6. Git saves all file changes to a directory as a compressed database. 

a. You modify files in Working Directory

b. You notify that want to save changes in your Staging Area

c. After you Commit the file changes are saved in the Git directory


1. git config --global "Derek Banas" 

2. git config --global

3. git config --global core.editor "vim" # Set editor as vim

4. git config --global core.editor "edit -w" # Set editor as Text Wrangler Mac

5. git config --list # Show settings

6. git help OR git help [COMMAND] OR git help add

7. ---------------- Track a directory ----------------

a. Go to directory

b. ls -a shows all files

c. git init # Creates the .git directory

8. ---------------- Start tracking files ----------------

a. By type : git add *.java

b. By name : git add AndroidManifest.xml

9. ---------------- Ignore Files ----------------

a. Create a .gitignore file


10. ---------------- git commit -m 'Initial project version' 

a. Commits the changes and sets an abbreviated commit message

11. ---------------- git status ----------------

a. Shows the state of your files meaning if they are tracked, have been modified and the branch your on.

12. ---------------- Stage A Modified File ----------------

a. Change the file and save

b. git diff # Shows what you changed, but haven't staged

c. git add AndroidManifest.xml # Stage file

d. git diff --cached # Shows what has been staged, but not committed 

13. ---------------- Commit The Changes ----------------

a. commit # Opens the editor we defined above or vi

b. In vi click [ESC] i to enter insert mode

c. Type a heading that briefly explains the changes in 50 characters or less

d. Describes the original problem that is being addressed

e. Describes the specific change being made

f. Describes the result of the change

g. Describes any future improvements

h. Post a closes bug notation Closes-Bug: #1291621

i. Hit [ESC] and type wq to save and exit

j. git commit -a -m 'Changed comment' # Skips staging and commit message

14. ---------------- Remove a File ----------------

a. rm DeleteMe.txt # If you remove a file it shows as "Changed but not updated"

b. git status # If you remove a file it shows as "Changed but not updated"

c. git rm DeleteMe.txt

d. git status # Shows that the file was deleted

e. If you have committed a file to be removed you must add the -f option

f. git rm --cached DeleteMe.txt # Keep file, but remove from staging area

g. git mv DeleteMe.txt Delete.txt # Renames a file

15. ---------------- Log Commit History  ----------------

a. git log # Shows all of the previous commit messages in reverse order

b. git log --pretty=oneline # Shows commits on one line

c. git log --pretty=format:"%h : %an : %ar : %s" 

I. %h - Abbreviated Hash  

II. %an - Authors Name

III. %ar - Date Changed

IV. %s - First Line of Comment

d. git log -p -2 # Shows the last 2 commit changes

e. git log --stat # Prints abbreviated stats

f. git log --since=1.weeks # Show only changes in the last week

g. git log --since="2014-04-12" # Show changes since this date

h. git log --author="Derek Banas" # Changes made by author

i. git log --before="2014-04-13" # Changes made before this date

16. ---------------- Undoing a Commit ----------------

a. git commit --amend # If you want to change your previous commit

b. Normally done if you forgot to stage a file, or to change the commit message

17. ---------------- Unstage a File ---------------- 

a. git reset HEAD AndroidManifest.xml

28 Responses to “Git Video Tutorial”

  1. sohelelite says:

    There r many tutorial on git but this is the best of all

  2. Roni says:

    is android tutorial over?

  3. Sahil Dave says:

    Hey Derek, can you please make a tutorial on Back-end services for android apps, like or Google App Engine?

  4. Sako says:

    Hi Derek,

    This is wonderful. Can we get one on “GIT Extensions” too?

    Thanks a lot

  5. Mr. Jimmy says:

    Hi Derek, can you make a tutorial about SVN?

  6. Glen says:

    Hey Derek, I love the pace of your videos, it always seems to be just right and doesn’t waste my time. We can always stop and replay parts when we feel a need to. I think you really have a gift for this. Thanks for spending your time to share it!

  7. Derek,

    Super happy you are doing a tutorial on this, I love your style.

    I am having an issue where when I do the “git diff” command, it essentially locks up the terminal so that I am forced to restart the terminal so that I can enter more commands. Here is a screenshot of what is going on:

    Thanks for all your help.

  8. Vcoder says:

    Great git tutorials, thank you =)

  9. Manuel Silverio says:

    This is definitely the best Git tutorial on the web.. Thanks!

  10. Yehuda Ginsburg says:

    Hi Derek

    First Thank you for your site its the best.

    I’ve Learning this video few times and i have a question:
    what is the different between this command of unstaging to other command:
    A.git rm –cached AndroidManifest.xml #
    B.git reset HEAD AndroidManifest.xml #
    from what i see both commands do unstaging but not delete.


    • Derek Banas says:

      Hi Yehuda,

      There are 3 places where you can have files being the tree, the index and the working copy. git reset HEAD resets the index to the state it was in before you started making changes to the index. git rm removes a file from the working directory and the index when you commit. i hope that helps 🙂

  11. Nasser says:

    Thank you derek for helping us and I hope that you keep the good work ..

Leave a Reply

Your email address will not be published.