東川印記

一本東川,笑看爭龍斗虎;寰茫兦者,度橫佰昧人生。

git for bitbucket

2014年5月2日星期五



代码托管
    github,google code,bitbucket
    github private需要花钱,google code深奥的简洁,最后选择bitbucket;
    bitbucket 无限的private仓库,好吧,最关键的是支持中文。。。。。

创建项目,git方式

设置SSH密钥
   
文字化就是:
1.在终端中运行ssh-keygen。  
2.然后一路enter,直接到结束。不要理会中间的输入。   
3 打开用户目录下.ssh/id_rsa.pub文件,复制其内容。

  1. senrsl@senrsl-desktop:~$ ssh-keygen
  2. Generating public/private rsa key pair.
  3. Enter file in which to save the key (/home/senrsl/.ssh/id_rsa):
  4. Created directory '/home/senrsl/.ssh'.
  5. Enter passphrase (empty for no passphrase):
  6. Enter same passphrase again:
  7. Your identification has been saved in /home/senrsl/.ssh/id_rsa.
  8. Your public key has been saved in /home/senrsl/.ssh/id_rsa.pub.
  9. The key fingerprint is:
  10. 3c:47:59:8e:6b:ad:85:54:c7:33:c9:b7:85:81:c9:f6 senrsl@senrsl-desktop
  11. The key's randomart image is:
  12. +--[ RSA 2048]----+
  13. |           .o=o+ |
  14. |           *=.B o|
  15. |          =... +o|
  16. |       . o +  E. |
  17. |        S = o    |
  18. |         + o     |
  19. |          .      |
  20. |                 |
  21. |                 |
  22. +-----------------+
  23. senrsl@senrsl-desktop:~$ ssh -v
  24. OpenSSH_5.9p1 Debian-5ubuntu1.2, OpenSSL 1.0.1 14 Mar 2012
  25. usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
  26.            [-D [bind_address:]port] [-e escape_char] [-F configfile]
  27.            [-I pkcs11] [-i identity_file]
  28.            [-L [bind_address:]port:host:hostport]
  29.            [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
  30.            [-R [bind_address:]port:host:hostport] [-S ctl_path]
  31.            [-W host:port] [-w local_tun[:remote_tun]]
  32.            [user@]hostname [command]
  33. senrsl@senrsl-desktop:~$ cd test/bitbucket/
  34. senrsl@senrsl-desktop:~/test/bitbucket$ ll
  35. 总用量 8
  36. drwxrwxr-x 2 senrsl senrsl 4096  5月  2 14:14 ./
  37. drwxrwxr-x 4 senrsl senrsl 4096  5月  2 14:14 ../
  38. senrsl@senrsl-desktop:~/test/bitbucket$ cd test
  39. senrsl@senrsl-desktop:~/test/bitbucket/test$ ll
  40. 总用量 8
  41. drwxrwxr-x 2 senrsl senrsl 4096  5月  2 14:15 ./
  42. drwxrwxr-x 3 senrsl senrsl 4096  5月  2 14:15 ../
  43. senrsl@senrsl-desktop:~/test/bitbucket/test$ git init
  44. 程序"git"尚未安装。  您可以使用以下命令安装:
  45. sudo apt-get install git
  46. senrsl@senrsl-desktop:~/test/bitbucket/test$ sudo apt-get install git
  47. [sudo] password for senrsl:
  48. 正在读取软件包列表... 完成
  49. 正在分析软件包的依赖关系树      
  50. 正在读取状态信息... 完成      
  51. 下列软件包是自动安装的并且现在不需要了:
  52.   liblaunchpad-integration1 indicator-status-provider-pidgin pidgin-data
  53.   libgtkspell0
  54. 使用'apt-get autoremove'来卸载它们
  55. 将会安装下列额外的软件包:
  56.   git-man liberror-perl
  57. 建议安装的软件包:
  58.   git-daemon-run git-daemon-sysvinit git-doc git-el git-arch git-cvs git-svn
  59.   git-email git-gui gitk gitweb
  60. 下列【新】软件包将被安装:
  61.   git git-man liberror-perl
  62. 升级了 0 个软件包,新安装了 3 个软件包,要卸载 0 个软件包,有 38 个软件包未被升级。
  63. 需要下载 6,617 kB 的软件包。
  64. 解压缩后会消耗掉 15.2 MB 的额外空间。
  65. 您希望继续执行吗?[Y/n]y
  66. 获取:1 http://cn.archive.ubuntu.com/ubuntu/ precise/main liberror-perl all 0.17-1 [23.8 kB]
  67. 获取:2 http://cn.archive.ubuntu.com/ubuntu/ precise/main git-man all 1:1.7.9.5-1 [630 kB]
  68. 获取:3 http://cn.archive.ubuntu.com/ubuntu/ precise/main git i386 1:1.7.9.5-1 [5,963 kB]
  69. 下载 6,617 kB,耗时 4秒 (1,631 kB/s)
  70. Selecting previously unselected package liberror-perl.
  71. (正在读取数据库 ... 系统当前共安装有 180907 个文件和目录。)
  72. 正在解压缩 liberror-perl (从 .../liberror-perl_0.17-1_all.deb) ...
  73. Selecting previously unselected package git-man.
  74. 正在解压缩 git-man (从 .../git-man_1%3a1.7.9.5-1_all.deb) ...
  75. Selecting previously unselected package git.
  76. 正在解压缩 git (从 .../git_1%3a1.7.9.5-1_i386.deb) ...
  77. 正在处理用于 man-db 的触发器...
  78. 正在设置 liberror-perl (0.17-1) ...
  79. 正在设置 git-man (1:1.7.9.5-1) ...
  80. 正在设置 git (1:1.7.9.5-1) ...
  81. senrsl@senrsl-desktop:~/test/bitbucket/test$ git init
  82. Initialized empty Git repository in /home/senrsl/test/bitbucket/test/.git/
  83. senrsl@senrsl-desktop:~/test/bitbucket/test$ git remote add origin git@bitbucket.org:dcjz/test.git
  84. senrsl@senrsl-desktop:~/test/bitbucket/test$ echo "# This is my README" >> README.md
  85. senrsl@senrsl-desktop:~/test/bitbucket/test$ git add REDEME.md
  86. fatal: pathspec 'REDEME.md' did not match any files
  87. senrsl@senrsl-desktop:~/test/bitbucket/test$ git add README.md
  88. senrsl@senrsl-desktop:~/test/bitbucket/test$ git commit -m "First commit. Adding a README"
  89. [master (root-commit) 7680e52] First commit. Adding a README
  90.  Committer: senRsl <senrsl@senrsl-desktop.(none)>
  91. Your name and email address were configured automatically based
  92. on your username and hostname. Please check that they are accurate.
  93. You can suppress this message by setting them explicitly:
  94.     git config --global user.name "Your Name"
  95.     git config --global user.email you@example.com
  96. After doing this, you may fix the identity used for this commit with:
  97.     git commit --amend --reset-author
  98.  1 file changed, 1 insertion(+)
  99.  create mode 100644 README.md
  100. senrsl@senrsl-desktop:~/test/bitbucket/test$ git push -u origin master
  101. The authenticity of host 'bitbucket.org (131.103.20.167)' can't be established.
  102. RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40.
  103. Are you sure you want to continue connecting (yes/no)? ^C
  104. senrsl@senrsl-desktop:~/test/bitbucket/test$ git push -u origin master
  105. The authenticity of host 'bitbucket.org (131.103.20.168)' can't be established.
  106. RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40.
  107. Are you sure you want to continue connecting (yes/no)? yes
  108. Warning: Permanently added 'bitbucket.org,131.103.20.168' (RSA) to the list of known hosts.
  109. Counting objects: 3, done.
  110. Writing objects: 100% (3/3), 249 bytes, done.
  111. Total 3 (delta 0), reused 0 (delta 0)
  112. To git@bitbucket.org:dcjz/test.git
  113.  * [new branch]      master -> master
  114. Branch master set up to track remote branch master from origin.
  115. senrsl@senrsl-desktop:~/test/bitbucket/test$ git add .
  116. senrsl@senrsl-desktop:~/test/bitbucket/test$ git commit -m 'version 1.0.0'
  117. [master 4bad3fd] version 1.0.0
  118.  Committer: senRsl <senrsl@senrsl-desktop.(none)>
  119. Your name and email address were configured automatically based
  120. on your username and hostname. Please check that they are accurate.
  121. You can suppress this message by setting them explicitly:
  122.     git config --global user.name "Your Name"
  123.     git config --global user.email you@example.com
  124. After doing this, you may fix the identity used for this commit with:
  125.     git commit --amend --reset-author
  126.  25 files changed, 183 insertions(+)
  127.  create mode 100644 AndroidManifest.xml
  128.  create mode 100644 bin/AndroidManifest.xml
  129.  create mode 100644 bin/classes/com/dc/activity/CommonActivity.class
  130.  create mode 100644 bin/classes/com/dc/activity/TestActivity.class
  131.  create mode 100644 bin/classes/com/dc/test/BuildConfig.class
  132.  create mode 100644 bin/classes/com/dc/test/R$attr.class
  133.  create mode 100644 bin/classes/com/dc/test/R$drawable.class
  134.  create mode 100644 bin/classes/com/dc/test/R$string.class
  135.  create mode 100644 bin/classes/com/dc/test/R$style.class
  136.  create mode 100644 bin/classes/com/dc/test/R.class
  137.  create mode 100644 bin/jarlist.cache
  138.  create mode 100644 gen/com/dc/test/BuildConfig.java
  139.  create mode 100644 gen/com/dc/test/R.java
  140.  create mode 100644 ic_launcher-web.png
  141.  create mode 100644 libs/android-support-v4.jar
  142.  create mode 100644 proguard-project.txt
  143.  create mode 100644 project.properties
  144.  create mode 100644 res/drawable-hdpi/ic_launcher.png
  145.  create mode 100644 res/drawable-mdpi/ic_launcher.png
  146.  create mode 100644 res/drawable-xhdpi/ic_launcher.png
  147.  create mode 100644 res/drawable-xxhdpi/ic_launcher.png
  148.  create mode 100644 res/values/strings.xml
  149.  create mode 100644 res/values/styles.xml
  150.  create mode 100644 src/com/dc/activity/CommonActivity.java
  151.  create mode 100644 src/com/dc/activity/TestActivity.java
  152. senrsl@senrsl-desktop:~/test/bitbucket/test$ git remote add origin git@bitbucket.org:dcjz/test.git
  153. fatal: remote origin already exists.
  154. senrsl@senrsl-desktop:~/test/bitbucket/test$ git push origin master
  155. Counting objects: 48, done.
  156. Delta compression using up to 4 threads.
  157. Compressing objects: 100% (35/35), done.
  158. Writing objects: 100% (47/47), 631.72 KiB, done.
  159. Total 47 (delta 2), reused 0 (delta 0)
  160. To git@bitbucket.org:dcjz/test.git
  161.    7680e52..4bad3fd  master -> master
  162. senrsl@senrsl-desktop:~/test/bitbucket/test$ git config --list"
  163. > ^C
  164. senrsl@senrsl-desktop:~/test/bitbucket/test$ git config -list
  165. error: did you mean `--list` (with two dashes ?)
  166. senrsl@senrsl-desktop:~/test/bitbucket/test$ git config --list
  167. core.repositoryformatversion=0
  168. core.filemode=true
  169. core.bare=false
  170. core.logallrefupdates=true
  171. remote.origin.url=git@bitbucket.org:dcjz/test.git
  172. remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
  173. branch.master.remote=origin
  174. branch.master.merge=refs/heads/master
  175. senrsl@senrsl-desktop:~/test/bitbucket/test$ git config --global user.name "senRsl DC"
  176. senrsl@senrsl-desktop:~/test/bitbucket/test$ git config --global user.email senRsl@163.com
  177. senrsl@senrsl-desktop:~/test/bitbucket/test$ git config --list
  178. user.name=senRsl DC
  179. user.email=senRsl@163.com
  180. core.repositoryformatversion=0
  181. core.filemode=true
  182. core.bare=false
  183. core.logallrefupdates=true
  184. remote.origin.url=git@bitbucket.org:dcjz/test.git
  185. remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
  186. branch.master.remote=origin
  187. branch.master.merge=refs/heads/master
  188. senrsl@senrsl-desktop:~/test/bitbucket/test$ git config user.name
  189. senRsl DC
  190. senrsl@senrsl-desktop:~/test/bitbucket/test$ git commit -a -m 'version 1.0.1'
  191. [master 89c671d] version 1.0.1
  192.  1 file changed, 1 insertion(+)
  193. senrsl@senrsl-desktop:~/test/bitbucket/test$ git push origin master
  194. Warning: Permanently added the RSA host key for IP address '131.103.20.167' to the list of known hosts.
  195. Counting objects: 5, done.
  196. Delta compression using up to 4 threads.
  197. Compressing objects: 100% (2/2), done.
  198. Writing objects: 100% (3/3), 297 bytes, done.
  199. Total 3 (delta 1), reused 0 (delta 0)
  200. To git@bitbucket.org:dcjz/test.git
  201.    4bad3fd..89c671d  master -> master
  202. senrsl@senrsl-desktop:~/test/bitbucket/test$ gedit ~/.hgrc
  203. senrsl@senrsl-desktop:~/test/bitbucket/test$ git commit -a -m 'version 1.0.2'
  204. [master 3f9ba27] version 1.0.2
  205.  1 file changed, 1 insertion(+)
  206. senrsl@senrsl-desktop:~/test/bitbucket/test$ git push origin master
  207. Counting objects: 5, done.
  208. Delta compression using up to 4 threads.
  209. Compressing objects: 100% (3/3), done.
  210. Writing objects: 100% (3/3), 308 bytes, done.
  211. Total 3 (delta 1), reused 0 (delta 0)
  212. To git@bitbucket.org:dcjz/test.git
  213.    89c671d..3f9ba27  master -> master
  214. senrsl@senrsl-desktop:~/test/bitbucket/test$
感觉很诡异,在终端配置了邮件跟用户,跟网站上的一样了,结果还提示

于是就点创建别名进行绑定。。。。。。
好诡异的感觉。。。。


修改git config配置文件
查看当前配置:git config --list


修改你的标识(your identity)


创建相应目录,比方说test/test/
然后cd进去


新上传项目
git init //初始化
git add . //本地准备添加,"."是表示所有文件
git commit -m 'version 1.0.0' //引号里是说明信息
git remote add origin git@bitbucket.org:dcjz/test.git //这个应该是增加远端地址
git push origin master  //上传发布
修改本地文件上传
增加文件的时候
    git add .
    git commit -a -m 'version 1.0.3'
    git push origin master
不是增加,只是修改的话
    git commit -a -m 'version 1.0.3'
    git push origin master


创建一个Tag



删除某个tag



从服务器下载项目


会新创建test文件夹,然后下载进去

trunk  branches tags
主干   分支        标签
主干是标准版,日常开发;
分支,阶段性的release版本,客户定制版本;
tags目录一般是只读的,阶段性的发布版本,作为里程碑进行存档;


--
senRsl
2014-05-02 15:53
GMT+8 @Beijing Tongzhou

没有评论 :

发表评论