emailconfirmed, nsInternRO, nsInternRW, Administrators
3,356
edits
(created full git tutorial) |
|||
| (4 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== | == Download & Install Git on your Machine == | ||
open up your Terminal / Console and type | open up your Terminal / Console and type | ||
| Line 9: | Line 9: | ||
== | == Setup == | ||
'''If you're using git for the first time''', you might want to setup some configuration settings: | '''If you're using git for the first time''', you might want to setup some configuration settings: | ||
| Line 23: | Line 23: | ||
git config --global color.status auto | git config --global color.status auto | ||
git config --global color.branch auto | git config --global color.branch auto | ||
Sometimes you have to enter messages in a terminal editor and the default may be vim or emacs. If you like to use another editor, there's this global option: | |||
git config --global core.editor "nano" | |||
These settings are global (for your machine), so you only need to do this once. | These settings are global (for your machine), so you only need to do this once. | ||
== Create the Project Folder == | |||
== | |||
Create or select your project folder, '''c'''hange to this '''d'''ir in terminal and init git. This will create a ".git" folder inside your project. If you want to remove the git version control for whatever reason, you just need to delete this folder | Create or select your project folder, '''c'''hange to this '''d'''ir in terminal and init git. This will create a ".git" folder inside your project. If you want to remove the git version control for whatever reason, you just need to delete this folder | ||
| Line 40: | Line 43: | ||
== | == Init the Project Folder == | ||
Now, let's add git to our new folder: | Now, let's add git to our new folder: | ||
| Line 52: | Line 55: | ||
This is acutally a command, you should remember! | This is acutally a command, you should remember! | ||
== | == Adding Files == | ||
The status should say something like this: | The status should say something like this: | ||
| Line 87: | Line 90: | ||
== | == Change Stuff == | ||
Open REAMDE.md and type something. | Open REAMDE.md and type something. | ||
| Line 100: | Line 103: | ||
== | == Commit Changes == | ||
Commit early and commit often! Really, I mean that! And don't put in glibberish, make a useful comment about what you did: | Commit early and commit often! Really, I mean that! And don't put in glibberish, make a useful comment about what you did: | ||
| Line 126: | Line 129: | ||
== | == Change Stuff (Again) == | ||
Repeat step 5 and change the README.md file. | Repeat step 5 and change the README.md file. | ||
| Line 169: | Line 172: | ||
== | == Commit (Again) == | ||
Commit early and commit often! Really, I mean that! And don't put in glibberish, make a useful comment about what you did: | Commit early and commit often! Really, I mean that! And don't put in glibberish, make a useful comment about what you did: | ||
| Line 212: | Line 215: | ||
== | == What's the diff? == | ||
Time for a cup of fresh coffee. Now you have a nice version control system for your project and you can work with git locally. | Time for a cup of fresh coffee. Now you have a nice version control system for your project and you can work with git locally. | ||
| Line 273: | Line 276: | ||
== | == GUI or not to GUI == | ||
Though, if you're not a nerd, you might enjoy a decent graphical user interface. Time to grab the GitHub.app | Though, if you're not a nerd, you might enjoy a decent graphical user interface. Time to grab the GitHub.app | ||
* for [http://mac.github.com Mac] | * for [http://mac.github.com Mac] | ||
* for [http://windows.github.com Windows] | * for [http://windows.github.com Windows] | ||
Drag your project folder onto the app. | Drag your project folder onto the app. | ||
| Line 286: | Line 289: | ||
While we're still local, let's explore another really powerful git feature: | While we're still local, let's explore another really powerful git feature: | ||
== Branching == | |||
== | |||
Adding another branch to your git repo is like duplicating the whole project folder (including the git commit history) and working on a second, completely different version. Like a real folder, you can delete this branch later on or (unlike a real folder) merge it with the current main branch. | Adding another branch to your git repo is like duplicating the whole project folder (including the git commit history) and working on a second, completely different version. Like a real folder, you can delete this branch later on or (unlike a real folder) merge it with the current main branch. | ||
| Line 305: | Line 307: | ||
Create a new branch | Create a new branch | ||
git branch testing | git branch -b testing | ||
you can also add -v to see the latest commit: | you can also add -v to see the latest commit: | ||
| Line 391: | Line 393: | ||
'''Remember that up until this point, we were using git locally. Now, let's create an online repository to work with others''' | '''Remember that up until this point, we were using git locally. Now, let's create an online repository to work with others''' | ||
== Using Remote Git Servers == | |||
== | |||
You can extend your local git repository with an online git server. This has two advantages: | You can extend your local git repository with an online git server. This has two advantages: | ||
| Line 415: | Line 415: | ||
== | == Creating an Online Repository == | ||
If you've uploaded your public SSH key for your machine, you can continue setting up your user account and finally, create a new repository: | If you've uploaded your public SSH key for your machine, you can continue setting up your user account and finally, create a new repository: | ||
| Line 433: | Line 433: | ||
So, let's add the remote origin (btw, this will also work via ssh) | So, let's add the remote origin (btw, this will also work via ssh) | ||
git remote add origin ssh://myserver.com | git remote add origin ssh://myserver.com | ||
== | == Push Changes to the Server == | ||
Pushing Changes, means uploading to the server. Because you can have more than one remote server in your repository, you have to state its name: | Pushing Changes, means uploading to the server. Because you can have more than one remote server in your repository, you have to state its name: | ||
| Line 457: | Line 456: | ||
</source> | </source> | ||
== | == Changing Stuff (Again) == | ||
This time, we want to simulate someone else changing our sources. The easiest way for this demo, is to go to github.com and edit the Readme file. E.g. apply some formatting ('#' creates a headline), and give it a commit message. | This time, we want to simulate someone else changing our sources. The easiest way for this demo, is to go to github.com and edit the Readme file. E.g. apply some formatting ('#' creates a headline), and give it a commit message. | ||
== | == Pull or Fetch and Merge == | ||
Git has two commands to update itself from a remote repository: | Git has two commands to update itself from a remote repository: | ||
| Line 537: | Line 536: | ||
* to the official [http://gitref.org/index.html Git Reference @ gitref.org] | * to the official [http://gitref.org/index.html Git Reference @ gitref.org] | ||
[[Category: | [[Category:Git]] | ||
[[Category:Tutorial]] | [[Category:Tutorial]] | ||
[[Category:Michael Markert]] | [[Category:Michael Markert]] | ||