git distributed revision control and source code management. The goal of this article is to easily get a git repository up and running pushing and pulling, and making the installed version of git comparable with (the majority of) http://git-scm.com/book/en/ .
Git was developed by Linus Torvalds for use on the Linux Kernel, and other Open Source projects. According to a talk he gave for Google, he was searching for an SCM and used three criteria which brought the number of adequate systems to zero:
- Must be distributed.
- Must be fast.
- What you get out MUST BE EXACTLY what you put in, or you get an error.
Since there were no satisfactory options, he wrote Git.
There are lots of really good tutorials on git. Let's not re-invent the wheel. Here are some I know and like, but any search engine will show you lots of examples.
- Official documentation
- Video tutorials
- Free, good basic first-time tutorial
- The first section is free, the rest are paid.
- A really straightforward tutorial
If you're the only one using your project, or if you're creating something which will be shared in a distributed way, then you should start on your workstation. If you intend to have a central server which everyone uses as the "official" server (e.g. github) then it might be easier to create an empty repository there.
This section, describes creating the repository on your workstation.
Here's an example of creating a project on your workstation:
You're done. You've created a local repository. It's in the .git folder, so don't delete your hello folder unless you mean to lose everything.
Note: Your repository is the .git folder inside the main "hello" folder. If you delete ~/src/hello, then your repo is gone.
Now, let's say we make some edits:
Git needs you to specify that we want to keep the changes we just made, so we need to add it before we commit:
Look to the tutorials to go further.
In this section will cover setting up a git server for remote project management through SSH.
Note: The git server is only necessary if you intend to have an unauthenticated read-only server for people to get your code from. See here: http://git-scm.com/book/en/Git-on-the-Server-Git-Daemon
If you're not sure, then skip this section.
Start by creating the needed group, user, and home directory. The user uses the git-shell to prevent normal shell access.
Edit /etc/conf.d/git-daemon to change user from "nobody" to "git" and start the daemon.
SSH is the prefered method to handle the secure communications between client and server. For Git to work properly, you must have private/public key logins enabled and all client public keys added to /var/git/.ssh/authorized_keys. For more information and instructions on how to enable, create, and share keys, please see the SSH - Passwordless Authentication wiki page.
Create a Repository and make the First Commit
On the server:
Become user git to make sure all objects are owned by this user
Create a bare repository
On a the client station:
Clone a repository: