My wechat public account: Road of Cultivation in front, welcome to follow.

Background requirements

Although code hosting has GitHub in foreign countries and code cloud and CODING in China, sometimes companies also need to build a set of code hosting servers that can be accessed within the LAN.

I chose to build a Gitblit server. The project used the following environment: Windows 10 Education Edition, JDK 8.0.13, Gitblit1.8.0 Windows edition.

JDK installation and configuration of environment variables

Because Gitblit requires a JDK, you need to configure the Java environment. The latest JDK downloaded from the Java official website is 13.0.0. After my tests, I found an error. So we changed it to JDK8.0, and then it will work normally. Because the JDK8.0 on the official website requires an Oracle account to download and use, I specially share my JDK.

Link: pan.baidu.com/s/1EtmjZhKo… Extraction code: MM6P copy this section of content to open baidu web disk mobile App, more convenient operation oh

Configure JDK environment variables

Regardless of whether it is normal or not, the complete configuration here is as follows, “My computer” – right-click – “Properties” – (left) advanced system Settings – (lower right corner of the popup window) environment variable configuration, the window above is the user variable, the bottom is the system variable, later put all your variables are configured in the system variable!

Create JAVA_HOME with the value of your previous JDK installation directory, such as C: Program Files (x86)\Java\jdk1.8.0_101 create CLASSPATH with the value     .; %JAVA_HOME%\lib; %JAVA_HOME%\lib\tools.jar (note the first bit) edit Path and place the value at the front     %JAVA_HOME%\bin; %JAVA_HOME%\jre\bin;Copy the code

Check the installation and configuration

On the cli, enter the following two commands:

Gitblit server setup

Download the latest version of Gitblit at www.gitblit.com/.

After downloading, unzip the package to D:\ProgramFiles\gitblit. The file structure is as follows.

Make a copy of the defaults.properties file in your data directory and rename it my.properties. Then modify the gitblit.properties file. Comment out include = defaults.properties and add a line of code include = my.properties. Indicates the use of the my.properties configuration.

Modify the port and server IP address in the my.properties file. Change server.httpPort = 10101 and server.httpBindInterface = 192.168.1.42 (my local IP address is 192.168.1.42). Modify server httpsBindInterface = localhost last modified server certificateAlias = localhost.

To run the Gitblit service, run the gitblit. CMD command in the D: ProgramFiles\ Gitblit directory.

Then enter in the browser, https://localhost:8443 or http://192.168.1.42:10101/, if there is a similar to the following interface, then the server has been set up is complete. The default login account and password are admin. Remember to change the password after your first login.

PS: This screenshot is because I’ve already created my warehouse. And for testing purposes, I’ve added a few commits. If you follow the steps, an empty warehouse should be created after logging in using the admin account.

At this point, the Gitblit server is completed.

Gitblit creates users, version libraries, and assigns access rights

First log in to the server using the admin account, then create a user and assign access rights.

Then create the repository and set the repository access rights.

Setting an SSH Link

Run the following command in the console to generate SSH.

Explanation of command words:

CD ~/. SSH: Check whether. SSH directory exists

Mkdir ~/. SSH: If no. SSH directory exists, create an

Git config –global user.name “account” : set git global account

Git config –global user.email

Ssh-keygen -t rsa -c “email” : generates an SSH Key

In the OS user directory C:\Users\ temptations \. SSH find the id_rsa.pub file and copy the contents.

Log in to the Git server using the created Git account, for example, templation. Paste the contents of id_rsa.pub into SSh Keys and click Add.

Collaborate with others on the LAN

The content mentioned above can only be used locally, but we need to develop it together with other colleagues, so other computers in the same LAN can also connect to my computer and take my computer as a server, which requires some firewall Settings. (my computer is windows10.)

Open “Control Panel” – “Administrative Tools” – “Advanced Security Windows Defender Firewall” as shown:

Click inbound Rule on the left, and then New Rule on the right.

Note: the path below needs to be chosen correctly. Mine is 64-bit, so choose gitblit.exe at the bottom of amd64, or gitblit.exe at the bottom of ×86 if it is 32-bit.

And just keep clicking next.

The following name is arbitrary, click finish.

In this way, the same on other computers in a network can also login to your computer the gitblit (as a server), direct input address, http://192.168.1.42:10101/, at the same time can also be to pull and push the gitblit.

Note:

If you still cannot access the Gitblit server through the above method, please turn off the firewall of your computer. I use windows10 system, after closing the firewall as follows.

conclusion

Gitblit is a very handy, open source distributed version control system. The only problem I encountered was that I needed to use JDK1.8 and then needed to add a gitblit record to my computer firewall. Finally, if users in the LAN cannot access, you need to turn off the firewall of the computer.