Build a git repository on a USB flash drive

Source: Internet
Author: User
Tags hosting

Because there is a need to frequently switch between computers, such as working in a lab computer and on your own computer, the work code needs to be under the same version control. To meet this need, you can use a free git hosting server on the Web, such as GitHub, but free hosting projects and open source. If there is a git server that can be moved, the problem is solved, this article is a git server version of the solution to put inside the USB flash drive, of course, you have to ensure that your U disk is not lost.

Take windows as an example:

1. Install Git's management tool under Windows, choose Git Bash and git here. After you install it, right-click the desktop or select "Git Bash here" under the project file.

2, assume that the U-disk directory H:/code_repo/dcshop directory to establish a warehouse as a server, in turn, execute the following command:

CD H:/code_repodcshop          #切换当前目录到h磁盘

git--bare init--shared #创建以个空的仓库 and can be shared by multiple users

The last line git init is to create an empty git repository or reinitialize an existing repository. The bare parameter is used to make the Syncfiles directory equivalent to a bare warehouse (bare repository), and the shared parameter specifies that the warehouse is shared among multiple users. This equates to the creation of a repository as a service side. The directory structure of this warehouse can be different from the warehouse created later.

3, assume that the files to be synchronized in the D:syncfiles directory, now need to push the files in the D:syncfiles directory to the server warehouse, execute the following command in turn:

cd/d/syncfilesgit init                        false  #可选, turn off automatic conversion of LF line breaks to CRLF newline characters git Add.                        " Submit Information "  "origin"//Add a remote Repository, origin is an alias (git defaults to Origin)             git push Origin master   #将本地内容推送到服务端仓库中

If git commit has a problem, tip plase tell me who is? Is that you did not define your name and mailbox.

--Global"[email protected]"--global"Your Name "

When the above steps are completed, the files in the local d:syncfiles directory are pushed to the server repository. When there are changes to the file, you can submit the changes as follows:

" Submit Information " #以上步骤可以反复进行, when the work is over, it can be submitted to the server repository git push

4. Now assume that you want to synchronize in E:, the steps are as follows:

CD/Egit clone H:/code_repo/dcshop      false

After execution, you can see the Syncfiles directory under E: The structure of this directory is identical to the d:syncfiles (and can be different from the directory structure of the next h:syncfiles). If you make changes to this directory later, you can push the changes to the server-side warehouse as a 3rd step.

5. Synchronize changes from the service-side warehouse. Assuming that the d:syncfiles has been updated and pushed to the server-side warehouse, it needs to be synchronized in E:syncfiles. This step consists of two actions:

    • Remove the updated version from the service-side warehouse
    • Merging with a local warehouse

The steps are as follows:

cd/e/Syncfilesgit Pull Origin Master

The above shows a common operation in Git, but it doesn't involve the following:

    • Branch (branch)
    • Conflicts and mergers
    • Undo and Redo

To illustrate, there is a default branch in Git, that is, the master branch (the Master branch, which appears in the preceding command), which is automatically generated by Git. All of our operations were performed on the main branch, but we were unaware of its existence.

Attached to my. Git/config

[Core]    repositoryformatversion = 0    FileMode = False    bare = False    Logallrefupdates = True    symlinks = False    IgnoreCase = True    Hidedotfiles = Dotgitonly[remote "origin"]    fetch = +refs/heads/*:refs/remotes/origin/*    url = i:\\code_repo\\dcshop    puttykeyfile = [branch "master"]    Remote = origin    merge = refs/heads/ Master

Build a git repository on a USB drive (GO)

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.