Let godson small Ben really play a role-build your own GitHub server with 8089DDirectory
- Objective
- Service-side configuration for 8089D
- Client configuration for any computer
- Filter settings for. Gitignore
- Password-free-git user authentication configuration
- Other
Objective
This article focuses on two scenarios, the first scenario: the Github
space provided for each free user 0.5 Gb
, but only the public code, and if you want to Github
save the private code on it, you only have to be a paid user. Another scenario is that your private code does not want to be publicly available on the Internet, because you feel insecure and you just want to keep it inside your local LAN, but you want to use it for git
versioning. What to do? It's easy to build a git
server yourself.
Let's talk about what the conditions should be for a server to meet:
The server generally has the demand of uninterrupted power supply: If you want to do the code server, then the continuous power supply is necessary, select a dedicated server, must match UPS
, or with a laptop with a battery, is also a good choice.
The disk space requirements of the server, if your code server only allows to upload text files, do not allow to save executable files, then only need very little space.
If the hardware is expensive and few decades ago, people are not likely to use laptops to do this kind of thing, but now many people have more than one desktop, more than one notebook, especially a few years ago to buy some netbooks, limited performance, slow speed, basically idle state, the author has 3 similar netbooks, Used to do the code server just fine.
Godson small Ben just 8089D
can be a code server to really play the power, on the one hand, it comes with battery, do not have to worry about the sudden power outage caused by the system error (Linux system runtime once power outage may damage the system, sometimes can be used to command fsck repair, sometimes even need to reload the system), As a matter of fact, any netbook that doesn't have a completely wasted battery can be transformed into a code warehouse server. On the other hand is its low performance, use it to compile, do graphics processing is relatively slow, but do the code server is enough.
In theory, Windows
and Linux
both can be set up as a code server, Windows
only need to install additional ssh
Server software to start the ssh
service, while the installation is specifically Windows
prepared for the git shell
code server can also be configured, but given my configuration , posSSH
, and WinSSHD
toss a half-day-although the configuration is good-can also be from Linux
landing to the Windows
top-there are ssh
some garbled something, it is not recommended to take Windows
the modern code server.
The following describes how to Debian
configure on the.
Service-side configuration for 8089D
My 8089D
installation Debian 7
, some of the basic software are installed, but also need to install the following software and services:git
You can install it by using the following command:
aptitude install git
The system starts with the start sshd
-up service, which can be sysv-rc-conf
viewed by
Add an SSH user
sudo adduser git
Follow the prompts to set the user's password
Create a git
Warehouse directory
sudo mkdir /opt/github/mytest.git
Set the owner of the directory to that user
sudo chown -R git:git /opt/github/mytest.git
Switch to the user
su git
Initialize the directory to a bare repository
cd /opt/github/mytest.gitgit init --bare
OK, now the server configuration is all done
Client configuration for any computer
Next is the client configuration operation, Windows
and Linux
Unix
OSX
all can be as a client, as long as the ability to run ssh
and git
, can be used when the client.
Here you need to know the 8089D ip
, with the command ifconfig
can see, assuming our 8089D
ip
192.168.99.233
There are two ways to use the default remote repository name origin
and the other to specify the name yourself.
First of all, a simple method, the direct use of the git clone
command can be set up locally a remote repository copy, the default remote warehouse name is set to origin
the local directory mytest1
, the detailed command is as follows:
git clone ssh://[email protected]/opt/github/mytest.git mytest1
Follow the prompts to enter the ssh
user git
's password, and then put the clone in the small copy mytest.git
to the local mytest1
directory, then enter the directory .\mytest1\
using git remote -v
the command to view the current remote repository, as follows:
Air:loongson admin$ cd mytest1/Air:mytest1 admin$ ls -altotal 0drwxr-xr-x 3 admin staff 102 6 8 00:36 .drwxr-xr-x 3 admin staff 102 6 8 00:36 ..drwxr-xr-x 10 admin staff 340 6 8 00:37 .gitAir:mytest1 admin$ git remote -vorigin ssh://[email protected]/opt/github/mytest.git (fetch)origin
In addition to Method 2, first create an empty directory mytest2
, and then enter this directory using the git init
command to initialize the directory, and finally use the git remote add
command to manually add the remote repository, the detailed command is as follows:
Air:loongson admin$ mkdir mytest2Air:loongson admin$ cd mytest2Air:mytest2 admin$ ls -altotal 0drwxr-xr-x 3 admin staff 102 6 8 00:41 .drwxr-xr-x 4 admin staff 136 6 8 00:41 ..drwxr-xr-x 10 admin staff 340 6 8 00:42 .gitAir:mytest2 admin$ git initInitialized empty Git repository in /Users/admin/GitHub/loongson/mytest2/.git/
git remote add
add l8089D
a remote repository named by command
Air:mytest2 admin$ git remote add l8089D ssh://[email protected]/opt/github/mytest.git
Then use the command git remote -v
to see all the remote repository names and the correspondingurl
Air:mytest2 admin$ git remote -vl8089D ssh://[email protected]/opt/github/mytest.git (fetch)l8089D ssh://[email protected]/opt/github/mytest.git (push)Air:mytest2 admin$
It's almost finished now.
Filter settings for. Gitignore
In order to make sure that we don't waste space on uploading executable files, we need to add a new configuration file under the working directory .gitignore
, the following command:
touch ./.gitignorevi ./.gitignore
and configure it, there are two ways to configure, one is open mode, one is conservative mode.
Simply put, open mode is the default to submit all the files, in the configuration file to indicate what files are not submitted, assuming our executable file format *.o
, we do not want to submit all the executable file, then the configuration file contents are as follows:
*.o
Conservative mode on the contrary, it does not submit all the files by default, only the files listed in the configuration file, if we need to submit all *.c
and *.h
files, then the configuration file contents are as follows:
!*.c!*.h
The above is the filter settings for the file, also can be set for the directory, as follows.
Open mode, do not submit directory /opt/github/mytest1/others/
, the configuration file .gitignore
contents are as follows:
/opt/github/mytest1/others/
Conservative mode, submit directory only /opt/github/
, configuration file .gitignore
contents are as follows:
!/opt/github/
Password-free-git user authentication configuration
The current configuration method each time the push
code needs to enter git
the user's password, because we do not configure SSH public and private keys, configuration is very simple, so that each time you do not have to lose the password, as long as the client used ssh
by the user's public key collection, they are stored in id_rsa.pub
File, added to 8089D
the user git
's authentication list can be, that is, 8089D
on the /home/git/.ssh/authorized_keys
file, each line, if only one user, then directly id_rsa.pub
copy as authorized_keys
good.
The rest is to synchronize the code to the server from the client's working directory.
git add .git commit -m ""
If in mytest1
action, the command is as follows:
git push origin master
If in mytest2
action, the command is as follows:
git push l8089D master
The other operations are the same.
After the above configuration, now your 8089D
godson small can be used as a code server put into use,
Other
Freeblues
Version: 20150608
Links: http://my.oschina.net/freeblues/blog/464075
Let godson small Ben really play a role-build your own GitHub server with 8089D