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,176 responses to “Git tutorial, getting started with Git”

  1. http://81.70.102.154/isabell62h8605 Avatar

    References:

    How long does it take for natural testosterone to come back after steroids

    References:
    https://www.oddmate.com/@korybelmore276

  2. www.cn8610086.cn Avatar

    References:

    Best muscle growth pills

    References:
    https://git.louislabs.com/sheryl10v86744

  3. 39.101.170.62 Avatar

    References:

    Bodybuilding enhancers

    References:
    http://8.138.83.32:3000/cassiezubia030

  4. ajmix.in Avatar

    References:

    Anaobolic hormones lname what

    References:
    http://120.76.251.151:3000/winnier7407901

  5. 117.159.26.136 Avatar

    References:

    Best place to buy anabolic steroids online

    References:
    https://git.m.ctf.arrobe.fr/zrmestella6171

  6. twoheartsagency.com Avatar

    References:

    Testosterone injection dosage for muscle
    building

    References:
    http://101.132.168.104:3000/judihollar103

  7. skillsvault.co.za Avatar

    References:

    Legal supplements that work like steroids

    References:
    https://git.van-peeren.de/elizbethmurrel

  8. https://gitea.adber.tech Avatar

    References:

    How to order steroids online

    References:
    https://git.esen.gay/princessroseby

  9. 115.159.194.75 Avatar

    References:

    Is dbol legal in the us

    References:
    https://nauticauruguay.com/mariano41w8418

  10. movie.nanuly.kr Avatar

    References:

    Dangerous drugs that build muscle

    References:
    https://zm.aosenhw.com/@rickwills76051

  11. https://tageeapp.com Avatar

    References:

    Physiological effects of steroids

    References:
    https://www.51kimi.cn/darellapplebau

  12. 112.47.48.236 Avatar

    References:

    What is it called when the testes are affected by steriods

    References:
    https://git.apextoaster.com/ezraa58183348

  13. https://muwafag.com/ Avatar

    References:

    How long does prednisone withdrawal symptoms last

    References:
    http://www.xngel.com/@dolliea6345653?page=about

  14. tcodpractice.com Avatar

    References:

    Best way to get steroids

    References:
    https://gitea.diputadosalta.gob.ar/sofiamachado08

  15. jobteck.com Avatar

    References:

    Which body type is more common in men and associated with the most negative health risk?

    References:
    https://www.musicbingoquiz.com/wilsonwitt6870

  16. Binance账户创建 Avatar

    I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.

  17. lasigal.com Avatar

    References:

    Which of the following has been found to be a side effect of anabolic
    steroid use?

    References:
    https://git.lolpro11.me/sonyalunn06923/9914chenxil.top/wiki/Clenbuterol%3A-Fettkiller-oder-gef%C3%A4hrliches-Dopingmittel%3F

  18. shiatube.org Avatar

    References:

    Steroid cycle chart

    References:
    http://xianyuhome.cn:11013/aubreyakehurst

  19. hellomusic.app Avatar

    References:

    Steroidal medications

    References:
    http://geekhosting.company/dorothead99475

  20. http://120.201.125.140 Avatar

    References:

    Where are receptors for steroid hormones found

    References:
    https://git.davisdre.com/fredriccheyne

  21. 47.94.173.135 Avatar

    References:

    Best oral anabolic steroid

    References:
    https://musixx.smart-und-nett.de/alinaeller4790

  22. StephenGlona Avatar
    StephenGlona

    Awesome site you have here but I was curious if you knew of any user discussion forums that cover the same topics talked about here? I’d really like to be a part of group where I can get opinions from other knowledgeable individuals that share the same interest. If you have any suggestions, please let me know. Many thanks!
    https://mostbet-zerkaloonline.buzz/big-bass-bonanza-demo-bigbassbonanzaslots/

  23. git.youkehulian.cn Avatar

    References:

    What do steroids do to women’s bodies

    References:
    http://47.104.60.158:7777/maik7510693855

  24. gitea.zachl.tech Avatar

    References:

    Best way to take winstrol

    References:
    https://laviesound.com/toshabarnum79

Leave a Reply

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