My official account of WeChat: the road of front-line training.
Use background requirements
Although there are GitHub in foreign countries and code cloud and coding in China, sometimes companies need to build their own code hosting server that can be accessed in the LAN.
I chose to build a gitblit server. The environment of the project is: Windows 10 education version, JDK 8.0.13, gitblit 1.8.0 Windows version.
JDK installation and configuration environment variables
Because gitblit needs JDK, it needs to configure the Java environment. The latest JDK downloaded from Java official website is 13.0.0. After my test, I found that it would report an error. So change to jdk8.0, then you can run normally. Because jdk8.0 on the official website needs an Oracle account to download and use, I specially share my JDK.
Extraction code: mm6p
After copying this content, open Baidu network disk mobile app, operation is more convenient
Configure JDK environment variables
Regardless of the general situation, the complete configuration here is as follows,“My computer” – right click – “properties” (left) advanced system settings – (lower right corner of pop-up window) environment variable configuration,The top of the window is the user variable, and the bottom is the system variable. After that, configure all your variables in the system variable!
Create Java_ Home, the value is the installation directory of your JDK, such as C:: program files (x86) \ \ Java \ \ jdk1.8.0_ one hundred and one Create classpath, value is.;% JAVA_ HOME%\lib;% JAVA_ Home% / lib / tools.jar (note the first point) Edit path and put the value in the front% Java_ HOME%\bin;% JAVA_ HOME%\jre\bin;
Check installation and configuration
In the command line window, enter the following two lines:
Building gitblit server
Download the latest version of gitblit, official website: http://www.gitblit.com/ .
After downloading, unzip the compressed package to
D:\ProgramFiles\gitblitThe file structure is as follows.
In the data directory
defaults.propertiesMake a copy of the document and change it to
my.properties. Then modify it
include = defaults.propertiesComment it out and add a line of code
include = my.properties. Indicates use
my.propertiesThe port and server IP address in the file. modify
server.httpPort = 10101, modify
server.httpBindInterface = 192.168.1.42(my local IP address is
server.httpsBindInterface = localhostFinal revision
server.certificateAlias = localhost。
Run gitblit service, and
D:\ProgramFiles\gitblitRun under directory
And then enter it in the browser,
http://192.168.1.42:10101/If an interface similar to the following appears, the server has been built. The default login account and password areadmin. Remember to change the password after the first login.
PS: this screenshot is because I have created my warehouse. And for testing purposes, I’ve added several submissions. If you follow the steps, after logging in with the admin account, it should be an empty warehouse.
So far, the gitblit server has been built.
Gitblit creates users, version libraries, and assigns access rights
First, use the admin account to log in to the server, and then create users and assign access rights.
Then create the version library and set the access rights of the version library.
Set SSH link
Execute the following command in the console to generate SSH.
Explanation of command words:
cd ~/.ssh: check if the. SSH directory exists
mkdir ~/.ssh: if not, create a. SSH directory
git config --global user.name“Account”: set git global account
git config --global user.emailMailbox: set git global mailbox
ssh-keygen -t rsa -CMailbox: generate SSH key
In the user directory of the operating system
id_rsa.pubFile, copy out the contents.
Use the GIT account created, such as templation, to log in to the GIT server. Add ID to_ Paste the content from rsa.pub into SSH keys and click Add.
Collaborative development by others in LAN
The content mentioned above can only be used locally, but we need to work with other colleagues to develop it. Other computers in the same LAN can also connect to my computer and use my computer as a server. This requires some firewall settings（ My computer is windows 10
Open control panel, administrative tools and advanced security windows defender firewall, as shown in the figure
Click “inbound rule” on the left, and then click “new rule” on the right.
be careful: the path in the figure below should be selected correctly. Mine is 64 bit, so select gitblit.exe under the AMD64 file. If it is 32-bit, select × 86 file under gitblit. Exe.
Then keep clicking next.
The name below is just as easy as you like, and you can click finish.
In this way, other computers in the same LAN can also log in to gitblit in your computer (as a server) and enter the address directly, http://192.168.1.42 : 10101 /, you can also pull and push gitblit.
If you still can’t access the gitblit server in the LAN through the above method, please turn off the firewall of the computer. I’m using Windows 10 system. After closing the firewall, I can see as follows.
Gitblit is a very useful, open source distributed version control system. The only problem I encountered was that I needed to use JDK1.8, and then I needed to add a gitblit record in the computer firewall. Finally, if the LAN users can not access, the need to turn off the computer firewall.