Git tutorial, getting started with Git

Below is a short comprehensive description of getting Git up and running in just a few minutes. I personally use OSX as a development machine and so the installation part of Git will cover an installation on OSX. If you like to install Git on another platform please take a look at the Git installation documentation. There are a lot of other ways to install Git, but the one described below seems to bring the least hassle on OSX.

Install Git and add your first project

  • First download the installer at the Google Git OSX installer project, http://code.google.com/p/git-osx-installer/downloads/list after running the installer you are good to go.
  • After this easy GUI installation it’s time to startup the terminal, although if you really are into GUI’s you can also download and install OpenInGitGui which can be found at http://code.google.com/p/git-osx-installer/wiki/OpenInGitGui. In your terminal go to the directory where your website is located and initialize a new repository here.

    $cd site_directory
    $git init

    You should now get a response like “Initialized empty Git repository in site_directory/.git/”. The next step is to add the current directory and all of its contents to the repository.

    $git add .
    $git commit -m "Initial import"

    You will now see that all files and directories are committed.

Basically this is it, nothing more to it. You could now start working with Git. Off course we can configure the Git installation just a little bit to set things right.

Basic configuration of Git, ignoring files and configuring the user settings
Whenever you will type “git status” on the current directory you will see if there are any changes that need to be committed, if so you can add them with the “commit” command like we did before. One of the first problems that you will bump into is that your cache files will also be committed. I personally don’t want to commit automatically created cache files or user content. So how can we deal with this? We can create a “.gitignore” file in the root of our project. You can find an example of the .gitignore file below.

*.cache
files

Now any file that has the *.cache extension will be ignored, also all the user content in the files directory will be ignored. This keeps our repository clean. By executing “git show” after committing the .gitignore file you will see that our ignore rules are correctly interpreted.

When you view the Git commit log of the project (“git log”) you will see that Git has already automatically used an author name and email address in the commits we did so far. These values are automatically detected by Git that examined your system configuration. You can change your name and email by executing the following commands:

$git config --global user.name Sjoerd Maessen
$git config --global user.email youremail@address.com

Taking advantage of Git
Off course we didn’t install Git just to add one project and change some basic settings. The power in any version control system is to make checkouts, revert and diff changes. Below you can find some basic commands that you will need to master.

$git checkout thepath
$git diff commitid1 commitid2
$git diff -- filepath
$git revert commitid1

The commands are pretty self explaining like all other commands of Git. If you already worked with other version control systems their is one thing to be aware of, “git revert” doesn’t behave like “svn revert” for example. “Git revert” will do a new commit to reverse a previous one, if you would like to undo your changes you should use “git checkout” instead. The things I have showed above are only small aspects of what Git is capable of. Cloning repo’s, tagging, branching, patching and resolving conflicts are all aspects that will make your life a lot easier, check them out at the Git community book

One more thing
There are some Git GUI repository browsers available that let you view who, why and when something was committed. One that is easy to setup and PHP only is viewgit, give it a try it will just run from your webserver!

http://viewgit.sourceforge.net

Comments

1,550 responses to “Git tutorial, getting started with Git”

  1. pads.zapf.in Avatar

    References:

    Vind penge online casino høj udbetaling

    References:
    http://www.optionshare.tw/home.php?mod=space&uid=4406082

  2. gitea.jb1000.com Avatar

    References:

    Bedste danske casinoer for høje gevinster

    References:
    https://reruberrypi.rerurate.com/vetaschauer48

  3. actualites.cava.tn Avatar

    References:

    Udbetalingshastighed og procenter casino

    References:
    https://www.24propertyinspain.com/user/profile/1434317

  4. www.uria.dev Avatar

    References:

    Bedste udbetaling af gevinster

    References:
    https://gitea.cfpoccitan.org/melissawitmer2

  5. quanbixuetang.com Avatar

    References:

    Bedste slots med høj udbetaling

    References:
    https://www.giveawayoftheday.com/forums/profile/1833382

  6. z.duowenlvshi.com Avatar

    References:

    Gennemsigtige casino udbetalingsrater

    References:
    https://git.dinsor.co.th/petrasievier35

  7. metagap.ro Avatar

    References:

    Udbetaling af casino gevinster Danmark

    References:
    https://srsbkn.eu.org/jonahkramer59

  8. suryapowereng.in Avatar

    References:

    Statistik over casino gevinster

    References:
    https://music.1mm.hk/oweneiffel979

  9. http://warblog.hys.cz/user/bonegold15 Avatar

    References:

    Casinoer med flest vinderoplevelser

    References:
    http://zghncy.cn/home.php?mod=space&uid=952574

  10. fravito.fr Avatar

    References:

    Bedste udbetaling af gevinster

    References:
    https://intensedebate.com/people/sparkteller28

  11. chequeface01.bravejournal.net Avatar

    References:

    Danske casinoer med bedste odds og udbetaling

    References:
    http://okprint.kz/user/kevinbuffet75/

  12. etuitionking.net Avatar

    References:

    Udbetaling af store gevinster casino

    References:
    https://hedgedoc.info.uqam.ca/s/WMcqszvHV

  13. http://bioimagingcore.be Avatar

    References:

    Hvor får man den højeste casino udbetaling

    References:
    http://www.kaseisyoji.com/home.php?mod=space&uid=3996863

  14. https://sportpoisktv.ru Avatar

    References:

    RTP på danske casino sider

    References:
    https://lslv168.com/home.php?mod=space&uid=2540684

  15. dating.vi-lab.eu Avatar

    References:

    Online casino udbetalingsstatistik

    References:
    https://seychelleslove.com/@freyafenbury4

  16. shinhwaspodium.com Avatar

    References:

    Hvilke spillemaskiner giver den højeste udbetaling

    References:
    https://gitea.jobiglo.com/bretvigano0942

  17. git.stormrain.cn Avatar

    References:

    Online casino vinder chancer

    References:
    https://git.refinementservices.com/fihjeffry1500

  18. https://forums.ppsspp.org/ Avatar

    References:

    Bedste danske casinoer med høj RTP

    References:
    https://hedgedoc.eclair.ec-lyon.fr/s/s0BRWUgv4

  19. oiaedu.com Avatar

    References:

    Casino med flest vinderchancer

    References:
    https://bbs.ybk001.com/home.php?mod=space&uid=483860

  20. phoebe.roshka.com Avatar

    References:

    Bedste casino sider for høje indsatser

    References:
    https://reruberrypi.rerurate.com/vetaschauer48

  21. downarchive.org Avatar

    References:

    Live dealer casino høj udbetaling

    References:
    https://www.tianjinzhaopin.cn/home.php?mod=space&uid=1192323

  22. Aewhaelspago Avatar
    Aewhaelspago

    Hi there, yes this piece of writing is really fastidious and I have learned lot of things from it about blogging. thanks.
    Inca Queen

  23. Ianonspago Avatar
    Ianonspago

    An outstanding share! I’ve just forwarded this onto a coworker who has been doing a little homework on this. And he in fact bought me dinner simply because I stumbled upon it for him… lol. So allow me to reword this…. Thank YOU for the meal!! But yeah, thanks for spending the time to discuss this matter here on your blog.
    Book of Tut

  24. GichardMam Avatar
    GichardMam

    Today, I went to the beach front with my kids. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is completely off topic but I had to tell someone!
    Big Bass Floats My Boat

Leave a Reply

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