git实验之创建仓库
2015-12-06 09:26
204 查看
http://blog.csdn.net/crylearner/article/details/7685022
git --bare init
如果是需要作为服务器仓库的,推荐加—bare,否则以后其他仓库push代码到此仓库时会有一些麻烦。
具体可以参考:http://hi.baidu.com/mengdaant/item/62dc182908bf25f950fd87ff
添加文件
git add . // add all
git add \\*.txt // add all txt file
添加文件后,直接git commit就完成了仓库创建。
2.1 克隆远程仓库
git clone <name> <url> <directory>
这里,name可以不写,默认origin
directory也可以不写,默认使用远程git一样的根目录名。
2.2 添加远程仓库
git remoteadd <name> <url>
name可以任意取。 url必须是确实存在的git仓库。
git pull <name>
如果pull时提示“You asked me to pull without telling me whichbranch you want to merge with”,
说明本地有新建分支且已同步到服务器上,当从服务器下载代码时需要在本地config中配置该分支的merge信息。
配置时可以参考下面的例子:
$ git config branch.master.remote origin //master是分支名,origin是远程仓库名
$ git config branch.master.merge refs/heads/master
具体可参考http://hubingforever.blog.163.com/blog/static/171040579201232184549211/
git push <remote name> <branchname>
如果push时提示“ refusing to update checked out branch:refs/heads/master”,说明远程仓库创建是没有使用—bare选项。
解决这个冲突需要远程仓库管理员:
具体可以是将远程仓库当前分支切换到其他分支(如谁也不会使用的分支),
或者按照提示内容,设置denyCurrentBranch = ignore。
具体可参考http://hi.baidu.com/mengdaant/item/62dc182908bf25f950fd87ff
仓库创建
1. 本地新建一个git仓库
git --bare init如果是需要作为服务器仓库的,推荐加—bare,否则以后其他仓库push代码到此仓库时会有一些麻烦。
具体可以参考:http://hi.baidu.com/mengdaant/item/62dc182908bf25f950fd87ff
添加文件
git add . // add all
git add \\*.txt // add all txt file
添加文件后,直接git commit就完成了仓库创建。
2. 本地克隆一个远程仓库
2.1 克隆远程仓库git clone <name> <url> <directory>
这里,name可以不写,默认origin
directory也可以不写,默认使用远程git一样的根目录名。
2.2 添加远程仓库
git remoteadd <name> <url>
name可以任意取。 url必须是确实存在的git仓库。
3. 同步远程仓库代码到本地
git pull <name>如果pull时提示“You asked me to pull without telling me whichbranch you want to merge with”,
说明本地有新建分支且已同步到服务器上,当从服务器下载代码时需要在本地config中配置该分支的merge信息。
配置时可以参考下面的例子:
$ git config branch.master.remote origin //master是分支名,origin是远程仓库名
$ git config branch.master.merge refs/heads/master
具体可参考http://hubingforever.blog.163.com/blog/static/171040579201232184549211/
4. 同步本地代码到远程仓库
git push <remote name> <branchname>如果push时提示“ refusing to update checked out branch:refs/heads/master”,说明远程仓库创建是没有使用—bare选项。
解决这个冲突需要远程仓库管理员:
具体可以是将远程仓库当前分支切换到其他分支(如谁也不会使用的分支),
或者按照提示内容,设置denyCurrentBranch = ignore。
具体可参考http://hi.baidu.com/mengdaant/item/62dc182908bf25f950fd87ff
相关文章推荐
- Android数据存储之SQLite
- 第十四周--项目2二叉树排序树中查找的路径
- iOS开发 网络编程 Socket编程
- 天声人語 20151206 消えゆくか社員手帳
- 第十四周--项目1验证平衡二叉树
- Java闭包
- LeetCode 199 Binary Tree Right Side View
- dede cms
- mysql中文乱码问题
- 信息安全系统设计基础第十二周总结
- 指针学习心得与理解
- 人生第一次
- 指针学习心得与理解
- Linux学习【菜鸟篇】- 学习笔记- 挂载点以及vi的简单使用
- IntelliJ IDEA使用说明
- Avro技术应用_7. 将 Avro 数据读写到一个 Parquet 文件中 -- 待完善
- UML——顺序图、协作图
- Avro技术应用_6. Avro Format & Text Format 之间的转换 --待完善
- Java中的Stringbuffer类解析
- 【Leetcode】Set Matrix Zeroes