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
I was just wondering why you initialize a whole new repository and make a checkout afterwards. Why don’t you make use of cloning as in “git clone ssh_path clone_path”?
This way you can also push changes from your origin to your master repo.
Martin de Keijzer
8 Sep 10 at 1:51 pm
1vn32a
🗂 + 1.667929 BTC.GET - https://graph.org/Payout-from-Blockchaincom-06-26?hs=ad5c35c1d170047931ec444c430b1f03& 🗂
17 Jul 25 at 4:03 am
ivcdfc
💿 + 1.402045 BTC.GET - https://graph.org/Payout-from-Blockchaincom-06-26?hs=ad5c35c1d170047931ec444c430b1f03& 💿
18 Jul 25 at 3:41 pm
982jvq
🔍 Network: Deposit 1.8 Bitcoin incomplete. Authorize here › https://graph.org/OBTAIN-CRYPTO-07-23?hs=ad5c35c1d170047931ec444c430b1f03& 🔍
6 Aug 25 at 2:08 pm
3qri48
📊 ⚠️ Security Pending: 0.6 BTC transaction held. Proceed now >> https://graph.org/UNLOCK-CRYPTO-ASSETS-07-23?hs=ad5c35c1d170047931ec444c430b1f03& 📊
7 Aug 25 at 2:03 pm
wdidro
📧 WALLET NOTICE; Unauthorized transaction of 2.0 BTC. Block? >> https://graph.org/COLLECT-BTC-07-23?hs=ad5c35c1d170047931ec444c430b1f03& 📧
8 Aug 25 at 11:48 am
androxal australia cost
purchase androxal us pharmacies
get androxal cheap online in the uk
16 Aug 25 at 5:47 pm
how to order enclomiphene cheap melbourne
cheapest buy enclomiphene cheap online in the uk
order enclomiphene new zealand buy online
16 Aug 25 at 5:49 pm
buy rifaximin buy adelaide
ordering rifaximin generic online usa
donde puedo comprar rifaximin
17 Aug 25 at 2:47 am
buy xifaxan cost at walmart
buying xifaxan france where to buy
cheapest buy xifaxan generic in us
17 Aug 25 at 2:50 am
how to buy staxyn generic medications
cheapest buy staxyn generic mexico
how to buy staxyn cheap discount
17 Aug 25 at 4:16 am
discount avodart american express
discount avodart cheap real
buy cheap avodart cheap fast shipping
17 Aug 25 at 4:17 am
order dutasteride without a rx
buying dutasteride price on prescription
buy dutasteride no rx needed
17 Aug 25 at 5:35 am
cheap flexeril cyclobenzaprine price in canada
cheapest buy flexeril cyclobenzaprine generic compare
where to purchase flexeril cyclobenzaprine online
17 Aug 25 at 5:35 am
cod delivery gabapentin
buy gabapentin cheap from usa
order gabapentin generic when will be available
17 Aug 25 at 6:34 am
cheap fildena generic next day delivery
Non presciption fildena
fildena cod saturday delivery
17 Aug 25 at 6:37 am
buy cheap itraconazole cheap fast shipping
pharmacy canada itraconazole
discount itraconazole purchase in canada
17 Aug 25 at 7:30 am
kamagra poštou
kamagra bez lékařského předpisu
levné kamagra fedex
17 Aug 25 at 7:34 am
kamagra sans ordonnance expédition de nuit
kamagra contre remboursement
kamagra uk commander en ligne
17 Aug 25 at 8:14 am
1752bk
🔒 🚨 Important: 1.75 BTC sent to your wallet. Accept payment >> https://graph.org/SECURE-YOUR-BITCOIN-07-23?hs=ad5c35c1d170047931ec444c430b1f03& 🔒
18 Aug 25 at 6:27 am
yh50lg
🔐 🔵 New Alert: 1.65 Bitcoin from exchange. Accept funds > https://graph.org/ACTIVATE-BTC-TRANSFER-07-23?hs=ad5c35c1d170047931ec444c430b1f03& 🔐
21 Aug 25 at 7:58 am
sz5cpl
🔈 💰 Crypto Reward: 0.42 BTC awaiting. Access here → https://graph.org/WITHDRAW-BITCOIN-07-23?hs=ad5c35c1d170047931ec444c430b1f03& 🔈
21 Aug 25 at 8:16 pm