Build git repository on a USB stick.

Source: Internet
Author: User
Tags using git ruby on rails

Git is hot. There are three reasons:

    1. It is the work of the Great God Linus Torvalds, which naturally possesses the temperament and quality of God's second generation;
    2. Facilitates the development of productivity, GIT's distributed versioning concept is not the first, but is well suited to the collaborative approach of the open source community (there is no master-slave relationship)
    3. GitHub

GitHub is well known as the Code World of Facebook.

Facebook,twitter,microsoft,vmware,redhat,linkedin,yahoo and other companies on GitHub have established a number of repositories. Some well-known open source projects, such as jquery, and Ruby on rails,node.js all store src code on GitHub. GitHub is so successful that it makes many people misunderstand that git is github and that you have to connect to GitHub using Git. In fact, GitHub is just a Web site that provides git repository hosting services.

This article attempts to explain how to create a git repository on a USB flash drive (making the USB drive your private code cloud), and how to synchronize jobs on different clients. Building a git repository on a USB disk can meet a variety of scenarios, especially:

    1. Focus on privacy (no private repository can be created on GitHub on a regular account)
    2. Speed is slow, even when the network needs to be synchronized

But not for projects that require strong collaborate.

Pre-conditions

Put Git in the first place ... And then... We have two git ready computers, and a USB flash drive.

Start, 1, initialize local repository

Suppose there is an existing project that requires git to take over version control, then come to this%projct_home% directory (for example, my Git_sandbox)

Step 1.1

Initialization

$ git init git_sandbox

Step 1.2

Create a. gitignore file (under%project_home%, only valid for this project), exclude files that are not required to be submitted to repository (for example,. Svn,.class, Thumbs.db ...) under a path.

Step 1.3

To view the current file status, you can see a bunch of "untracked files"

$ git status

Step 1.4

Add all the "untracked files" to the index

$ git Add.

Step 1.5

Submit to Repository

$ git commit-m "initialized."

2, get the USB stick up.

Step 2.1

Plug in the USB stick to view the USB drive mount Path

$ mount

My path is "/volumes/kingston."

Step 2.2

Create a repository on the USB drive,

$ mkdir/volumes/kingston/workspace/usbgitspace/gitusb_sandbox

$ cd/volumes/kingston/workspace/usbgitspace/gitusb_sandbox

$ git init--bare

The repository created with the –bare option is called bare Repository, and it does not contain the working directory (which contains only the contents of the. git directory), so it is not appropriate to change the code on it. Bare Repository's main role is to be push and pull. According to Gitfaq's statement:

A quick rule of thumb never push into a repository that have a work tree attached to it until you know Doing.

Step 2.3

Back to local%project_home%, add the initialized USB repository as remote repository

$ git remote add Usb/volumes/kingston/workspace/usbgitspace/gitusb_sandbox

Push the local repository to the USB

$ git push USB master

3, sync to another computer

Step 3.1

Create a local repository on another computer

$ CD ~/my_gitspace/sandbox_win

$ git init

Step 3.2

Plug the USB stick to this computer, view the current mount path, add a USB flash drive as the current repository remote repository

$ git remote add Usb/cygdrive/f/workspace/usbgitspace/gitusb_sandbox

Step 3.3

Pull the contents off the USB stick.

$ git Pull USB Master

Okay, the code's synced to another machine.

4, test it.

Step 4.1

Change files, like README.txt

Step 4.2

$ git Add README.txt

$ git commit-m "update from another laptop"

$ git push USB master

Step 4.3

Insert back the original laptop

$ git Pull USB Master

Step 4.4

View commit History

$ git log

found that the records submitted on both computers are in log.

Well, success. Now the USB stick becomes your github, between you and your code, no more blocking.

Of course, finally, you need to make a backup of the USB flash drive regularly. Technology development to today, data security dependent on day is gone, there is no U disk, hard drive is reliable.

Original link: http://wuminqi.com/blog/2012/01/08/%E6%8A%8Agit-repository%E5%BB%BA%E5%88%B0u%E7%9B%98%E4%B8%8A%E5%8E%BB/

Build git repository on a USB stick.

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.