把Git Repository建到U盘上去
来源:互联网 发布:中华网邮箱注册软件 编辑:程序博客网 时间:2024/04/30 14:35
前提条件
先把git给装好了…然后…我们有了两台git ready的电脑(测试时一台电脑其实也是可以的,找2个不同的目录),和一个U盘。
开始,1,初始化本地repository
step 1.2把所有”untracked files”加入索引 $ git add .
step 2.1
step 2.2
在U盘上创建一个repository,
使用–bare选项创建的repository被称作bare repository,它不会包含working目录(只包含.git目录下的内容),所以不适合在上面改code。bare repository主要的作用就是被push和pull。根据GitFaq的说法:A quick rule of thumb is to never push into a repository that has a work tree attached to it, until you know what you are doing.
step 2.3
回到本地%project_home%,把初始化后的usb repository添加为remote repository
$ git remote add usb G:\study\study1
将本地的repository push到usb上
step 3.1
在另一台电脑上先创建一个本地repository
step 3.2
把U盘上的内容拉下来
$ git pull usb master
好了,代码同步到另一台机器上了
4, 测试一下
step 4.1
改动一下文件,比如README.txt
step 4.2
$ git add README.txt
$ git commit -m "update from another laptop"
$ git push usb master
step 4.3
插回原来的laptop
查看提交历史
$ git log
好了,成功。现在U盘成为了你的GitHub,你和你的代码之间,再没有阻隔。
最后,需要定期给U盘做一个备份。
先把git给装好了…然后…我们有了两台git ready的电脑(测试时一台电脑其实也是可以的,找2个不同的目录),和一个U盘。
开始,1,初始化本地repository
假设有一个存在的项目,需要由git接管版本控制,那么来到这个%projct_home%目录(例如我的study1)下
step 1.2把所有”untracked files”加入索引 $ git add .
step 1.3提交到repository $ git commit -m "initialized."
这个过程比较简单,和一般常见git管理项目没什么不同。重点在第二步。
step 2.1
插上U盘,查看U盘挂载路径(如果是unix 系统 $ mount 可能路径是”/Volumes/KINGSTON”)
window系统一般都是盘符,打开“我的电脑”就可以看到,我的是G盘
step 2.2
在U盘上创建一个repository,
$ mkdir study
$ cd study
$ mkdir study1
$ cd study1
使用–bare选项创建的repository被称作bare repository,它不会包含working目录(只包含.git目录下的内容),所以不适合在上面改code。bare repository主要的作用就是被push和pull。根据GitFaq的说法:A quick rule of thumb is to never push into a repository that has a work tree attached to it, until you know what you are doing.
step 2.3
回到本地%project_home%,把初始化后的usb repository添加为remote repository
$ git remote add usb G:\study\study1
将本地的repository push到usb上
usb 是远程仓库名字(自定义,可以定义为其他名字也可以)
$ git push usb master
step 3.1
在另一台电脑上先创建一个本地repository
$ cd F:\study\study1
$ git initstep 3.2
把U盘插到这个电脑上,查看当前挂载的路径,添加U盘作为当前repository的remote repository
$ git remote add usb G:\study\study1
把U盘上的内容拉下来
$ git pull usb master
好了,代码同步到另一台机器上了
4, 测试一下
step 4.1
改动一下文件,比如README.txt
step 4.2
$ git add README.txt
$ git commit -m "update from another laptop"
$ git push usb master
step 4.3
插回原来的laptop
$ git pull usb master
查看提交历史
$ git log
发现两台电脑上提交的记录都在log里面
在测试时,发现用git bash here进入输入git命令时,路径中的斜杠“\”需要转义,即需要双斜杠。如果是cmd进入仓库目录在输入git命令时,路径中斜杠“\”不用转义。
好了,成功。现在U盘成为了你的GitHub,你和你的代码之间,再没有阻隔。
最后,需要定期给U盘做一个备份。
0 0
- 把Git Repository建到U盘上去(转载)
- 把Git Repository建到U盘上去
- 把Git Repository建到U盘上去
- github 把当前的git存储push到线上的分支上去
- 使用git把本地文件放到github上去
- 把Ubuntu烧到U盘里
- mac git android studio 提交代码到git oschina上去
- git commit 不小心把账号密码文件提交上去并push到远程后,而且还merge到master分支后 怎么删除commit记录
- git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支
- git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支
- git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支
- git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支
- git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支,及常用指令
- git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支
- git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支
- git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支
- git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支
- git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支
- JZOJ.1728. Antimonotonicity
- Count and Say
- Sort Colors
- HDU 5655 CA Loves Stick(四根棍子能否拼成四边形)
- Shellcode的原理及编写
- 把Git Repository建到U盘上去
- 网络流ford-fulkerson方法(代码实现)
- Spring学习笔记二: Bean装配及生命周期
- 用servlet作为服务器进行登陆注册界面实现(项目篇)
- Valid Palindrome
- OpenSessionInViewFilter解决Hibernate懒加载异常
- redis集群的介绍
- hdu-1113 Word Amalgamation
- 二叉树