Git Learning Summary (5)--build git simple and efficient server

Source: Internet
Author: User

1. Mysysgit+gitblit installation process

1.1 Resources
Need to download the good resources (the company's 1.6,1.7+ please match the corresponding mysysgit+gitblit):
jdk1.6
Git-1.8.4-preview20130916.exe
Gitblit-1.2.1.rar
1.2 Installation
1.2.1 Git Bash installation
1) Double click on the pop-up installation page

2) Click on 2 times Next, enter the path selection, add a custom path;

3) Click Next to enter the selection component,

4) Click the next step 2 times, select the operating environment, select "Run Git from the Windows Command Prompt";

5) Click Next and select "Checkout as-is,commit unix-style line Endings";

6) Click Next, go to the Installation Progress page, wait for the installation to complete;

7) Click "Finish", the installation is complete, the desktop, Start menu, and the right-click menu appear the program, very convenient.

Add:
1. Start-up can be used, do not need to configure environment variables;
2. In the folder you want to use right-click Git Bash here, you can go directly to the command line in the directory, do not have to switch the path under the command line, is not very convenient. For example: Right-click under D:\hjj-repo

10) Testing
Enter "Git version" in the command line that appears, the following content is the installation success;

1.2.2Gitblit Installation

1) Direct decompression, catalogue optional;
2) configuration gitblit.properties;
A. Path: Gitblit directory/data/gitblit.properties, "notepad" open;
B. Locate the Server.httpport, set the port number for the HTTP protocol (e.g. 7070)
Server.httpsport, set the port number of the HTTPS protocol (for example: 7071)

C. Find Server.httpbindinterface and Server.httpsbindinterface, set the server IP address is empty, convenient for other people to access;

D. Save, and exit.
3) Testing
Run the Gitblit.cmd batch file under the Gitblit directory;
The running result is as follows and the operation succeeds.


2. Gitblit Web Operations
2.1 Administrator Server First login
Open the url:http://127.0.0.1:7070 in the browser (port is the port of your own configuration), in the upper right corner enter Admin/admin login; – Please remember to change the password (admin)


2.2 Creating a Warehouse

1) Select New Repository to enter the new warehouse and the "General" tab is as follows:

The "Access Permissions" tab is as follows:

2) "Save" is saved;
3) Ibid., create repository-02, after completion;

2.3 Creating a user

Navigation bar Select "Users" – select "New User" to enter the Create UI;


1) Create User A, the "General" tab

The Access Permissions tab 1 represents the Assigned warehouse, and 2 indicates the operations that can be performed in the warehouse;

2) Click "Save" to save and exit;
3) Similarly create user user-b, give permission Clone/push warehouse 2;
4) Similarly create user user-c grant permissions Clone/push warehouses 1 and 2;

3. Local Operations 3.1 clone server's Warehouse

1) First create a new operation folder, such as: "Hjj-repo";
2) menu select "Git Bash here", in the popup Command line window, enter:
Create a global user name:
git config–-global user.name "name";

git clone http://Service Host IP Port/git/warehouse name. Git, for example:
git clone http://10.10.10.10:7070/git/repository-01.git
You will be prompted to enter a user name and password, input can be;
;

It is recommended not to use admin, with admin to create a high-privileged user as the administrator of the warehouse;
The Clone down repository appears in the local folder,


CD to the repository directory, and. Git, start the operation. is to create a local repository corresponding to the remote repository. For ease of operation, we give the remote warehouse an alias, usually "origin",
command is: Git remote add Origin http://xx.xx.xx.xx:7070/git/repository-01.git
Can not afford to, each time enter the full address URL;
The default is also OK, the default is "origin";

3.2 Local operation

1) Local basic operation:
A. Additional documentation
For example, I added two files "tables.txt" and "Chinese-form. txt"
View my local warehouse status, enter the command: Git status

Hint in the warehouse more than 2 files, you can use "add" to track;
B.add file into the track
Input commands: Git add tables.txt and git add Chinese-table. txt
and view the status as:

Shown to have 2 files included in the staging area, need to commit to our branch;
C.commit commits to the branch, enter the command: Git commit–m "comment content".
Be sure to add the contents of the comments to submit the success, it will be displayed in each operation and log;

appears as indicated by the arrows, stating that the contents of the staging area have been fully submitted for completion.
Multiple files, delete operations, etc. can be add–all with command git
The. bak file of files edited with Ultraedit/editplus and other editors should be deleted and not submitted;

Add:
1) Undo Modification – Modified, not yet put to staging area:
Before I submitted, I found that the content of the added document was incorrect, so I have to revert to the previous version immediately, and now I can have the following methods to make changes:
First: If I know what to delete, just manually change the files that need to be removed, then add to staging area, and finally commit.
Second: I can revert to the previous version directly in the previous way. Use git reset–hard head^.
Third: git checkout–-file name
2) Undo the changes-already in the staging area, and made the changes:
git checkout– filename This command will return the file to the state after it was put into staging area;

D. Commit to complete the branch of the local warehouse to complete the work, you can push (push) to the remote warehouse. But just as we normally use SVN, our submissions may conflict with others, so the correct code of practice is:
1) Check the status of the remote repository first; the command is: Git remote show repository name

Can see if someone pushes and updates the situation;
2) pull remote repository, command: Git fetch warehouse Name
If it is the first time to push, be sure to pull;

Up-to-date indicates that there is no difference between the local content and the last time you submitted it.
Here are 2 things:
1) Local modifications and remote modifications do not conflict;
Pull will automatically merge (merge) remote changes and local changes, git status will also show no changes;
2) local modifications and remote modification conflicts (e.g. just on the same line or same piece);
The program will automatically merge (merge), delete the original line, modified for you to modify. So make a comparison on the web side and pull again.
3) push to remote repository, command: git push repository name
If this is the first push, you need to enter the Git push-u repository name

4) View
Command view: Git remote show repository name;
Web view:/HTTP/xxxx:7070 (recommended Web view, more details)

Note 1: path;
Note the comments of the 2:commit;
Note 3: The contents of the submitted document;
Note: You can download it directly under the page title here. ZIP "or". Gz "package;

4. Daily Maintenance

2 Recommended Scenarios:
Scenario 1: Centralized management.
Set up 1-2 Admins, Members only View permissions. The Administrator is responsible for the server warehouse building and branch management, the remaining members are submitted to the Administrator audit, and then added by the administrator to master, a folder to build a warehouse, each warehouse to add the people can be previewed to achieve simple but efficient rights management.
This scheme is suitable for document management and so on, easy to maintain;
Scenario 2: Distributed management.
Set up 1-2 administrators, team members have pull/push authority. The code branch is created by the administrator and managed. By the team member in Pull/fork Branch, and modify and submit to the branch, after the administrator approves the approval, the administrator merges to the main branch. Typical distributed collaborative management; every step of the operation will have an exhaustive record on the server.

5. The basic common commands for Git are:

MKDIR:XX (Create an empty directory XX refers to the directory name)
PWD: Displays the path to the current directory.
Git init turns the current directory into a manageable git repository, creating a hidden. git file.
git add xx adds xx files to the staging area.
Git commit–m "XX" commits a file –m followed by a comment.
Git Status View warehouse status
git diff xx View xx file modified those content
git log View history
git reset–hard head^ or git reset–hard head~ fallback to previous version
(If you want to fallback to 100 versions, use Git Reset–hard head~100)
Cat xx View XX file contents
Git reflog View history's version number ID
Git checkout-xx all the changes to the XX file in the workspace.
git rm xx Delete xx file
Git remote add Origin https://github.com/tugenhua0707/testgit associated with a distant library
Git push–u (not required for the first time with-U) Origin master pushes the current master branch to the remote library
git clone https://github.com/tugenhua0707/testgit cloning from a remote repository
git checkout–b dev Create dev branch and switch to Dev branch
Git branch view all current branches
Git checkout master switches back to the master branch
git merge dev branches on the current branch
git branch–d dev Delete Dev branch
GIT branch name to create a branch
Git stash to hide the current job and resume work after resuming the site.
Git stash list view all hidden file lists
Git stash apply to recover hidden files, but the content is not deleted
git Stash Drop Delete file
Git stash pop recovers files while also deleting files
Git Remote to view information
Git remote–v View details of remote libraries
Git push origin master git pushes the master branch to the remote branch corresponding to the remote library

Git Learning Summary (5)--build git simple and efficient server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.