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

  1. https://hadln.net/ Avatar

    References:

    Did arnold use steroids

    References:
    https://git.nulldirect.com/dacialandsboro

  2. git.4lsa.com Avatar

    References:

    Losing weight on steroids

    References:
    https://hellomusic.app/buddymaestas96

  3. gogs.zlhuiyun.com Avatar

    References:

    How can i get steroids

    References:
    https://shirme.com/vonniebolt959

  4. 38.47.180.165 Avatar

    References:

    Anabolic steroids weight loss

    References:
    https://actsolution.iptime.org:3000/ernestinegaine

  5. 175.178.103.105 Avatar

    References:

    Trenbolone fat loss

    References:
    https://beatsong.app/lillianshipman

  6. git.freno.me Avatar

    References:

    Is it legal to order steroids online

    References:
    http://120.210.80.160:3000/chrisnewsom278

  7. git.archieri.fr Avatar

    References:

    Anabolic steroid cream for sale

    References:
    https://git.lmbrs.org/iiybert398980

  8. 101.37.147.115 Avatar

    References:

    Stacks near me

    References:
    https://laviesound.com/toshabarnum79

  9. yaseen.tv Avatar

    References:

    Buy online steriods

    References:
    http://8.138.249.120:3000/latia75407685

  10. gitslayer.de Avatar

    References:

    Positive effects of steroids on the body

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

  11. gitea.wgqcd.com Avatar

    References:

    Testosterone is a steroid

    References:
    https://git.hanumanit.co.th/jermainefunkho

  12. gitea.belanjaparts.com Avatar

    References:

    Best steroid for muscle recovery

    References:
    http://175.178.150.62:3002/jocelyndalgarn

  13. lasigal.com Avatar

    References:

    Legal muscle enhancement

    References:
    https://bfreetv.com/@sherlenederrin?page=about

  14. git.silvertone.com.au Avatar

    References:

    Top 10 bulking supplements

    References:
    https://www.kornerspot.com/@lateshadoyne78

  15. simapodcast.co.ls Avatar

    References:

    Can prednisone build muscle

    References:
    http://47.100.44.145:3000/beatrizlienhop

  16. www.howeasynetwork.com Avatar

    References:

    Which is not a consequence of long-term steroid use?

    References:
    https://vidspaceaiapp.com/@ethangilliam75?page=about

  17. pure.itsabouttimetv1.com Avatar

    References:

    What is the best muscle building supplement on the market

    References:
    https://gitea.zczcfiles.com.cn/michellgoodiss

  18. http://82.156.65.157/ Avatar

    References:

    Steroid muscle explosion

    References:
    https://dianyanai.com/brigette288976

  19. lafffrica.com Avatar

    References:

    Legitimate steroid sites

    References:
    https://live.eposbd.net/@marlapilpel308?page=about

  20. git.gotrobotics.org Avatar

    References:

    Steroids that help you lose weight

    References:
    https://git.fast-blast.uk/bartgamboa312

  21. http://112.124.40.88:5510/joellenstamm50 Avatar

    References:

    What is the best muscle builder on the market

    References:
    http://121.41.2.71:3000/danielagainey7

  22. 118.89.79.106 Avatar

    References:

    Pro and cons of testosterone boosters

    References:
    http://49.232.183.190:3000/jonathanledet5

  23. git.craigsau.dev Avatar

    References:

    Anabolic and hyperbolic are the two main types of steroids.

    References:
    https://goeed.com/@susiecuj58384?page=about

  24. saga.iao.ru Avatar

    References:

    How do steroids enter the body

    References:
    https://gitlab-rock.freedomstate.idv.tw/thedachamplin

  25. www.cives.pl Avatar

    References:

    What does steroids do to women

    References:
    http://118.178.172.49:3000/lesliegoldsmit

Leave a Reply

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