编程小贴士

给你的编程提供小点子


Eclipse使用git最基本流程

git有诸多好处,网上都说的很清楚了,在这里我不再赘述。对于我来说,私下里想做一些项目,而又不能很好的保存自己的代码和进行版本控制,这时候,就用到了git。下面,就以我个人为例讲讲git从0开始如何安装使用。

Step1 准备工作

msysgit,下载地址为http://msysgit.github.io/。

Eclipse IDE for Java EE Developers(必须是这个,自带Egit,或者自行安装Egit插件),在Eclipse官网下载,地址http://www.eclipse.org/downloads/。

github账号,github官网注册一个,地址https://github.com/。

廖雪峰的git教程,地址为http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000,讲得很好,我大概花了3个晚上的时间看,如果仅仅是为了安装上,可以先暂时略过,后面再看。

Step2 msysgit安装

一路next就行,注意可能会遇到360的拦截(该死,点击允许本程序所有操作或者安装前就退出360即可)。

Step3 git用户名和邮箱配置

单击开始菜单,打开Git Bush,

tips1000_2014-09-25_14-09-55

 

输入以下命令

git config –global user.name “Your Name”

git config –global user.email email@example.com

用户名和邮箱替换为自己的,为本台机器所有仓库指定用户名和email地址。

 

Step4 创建SSH Key

因为本地git仓库和远程的github仓库之间是通过ssh加密的,所以,还需要创建一个SSH Key。

输入以下命令

ssh-keygen -t rsa -C youremail@example.com

同样将邮箱替换为自己的。在路径C盘->用户->用户名,找到.ssh文件夹,打开就可以看到两个文件id_rsa和id_rsa.pub,

打开id_rsa.pub,将其中的内容复制下来(这就相当于一把钥匙,持有钥匙的人可以访问你的内容,下一个小结讲解这把钥匙的用途),下面是我的

tips1000_2014-09-25_14-09-541

 

Step5 与github上的仓库相关联

注册一个github账号

注册完成之后,点击右上角的settings(就是那个齿轮,设置的图标)

tips1000_2014-09-25_14-09-54

 

进入设置页面

tips1000_2014-09-25_14-09-54

选SSH Keys,点击add SSH key,就可以添加了,title随便填写,将从id_rsa.pub中复制的内容粘贴到这里。从此,gitgub仓库就能够识别你本地的仓库了。也就是 说,你离将本地代码推送到github上,或者将github上的代码克隆到本地,就只差一步了。(可参考廖雪峰前辈的教程先进行在非Eclipse下的 操作,更有感觉)

 

Step6 Egit的使用

首先,登入你的github账号,点击加号,选择New repositrory,创建一个新的仓库,如图所示。

tips1000_2014-09-25_14-09-542

名字叫做test2,其他都默认就好。

点击绿色按钮创建,就创建好了一个github仓库。

tips1000_2014-09-25_14-09-571

将地址复制下来,保存好备用。

 

打开Eclipse,像平常一样,新建一个web工程,或者其他你常用的工程。我这里工程叫做scott

tips1000_2014-09-25_14-09-57

右击项目,选择Team->Share Project,弹出如下窗口。

tips1000_2014-09-25_14-09-56

选择git,next,在弹出的界面上,①先勾选Use or create……,②createrepository,③勾选工程,④finish。

tips1000_2014-09-25_14-09-561

这时候,你就创建好了一个git工程,右击工程,选择Team,你可以像svn一样进行commit,synchronize等操作,但是,remote操作中,push是灰色的,表示还不能将代码推送到github仓库上去。

tips1000_2014-09-25_14-09-572

这时,打开Git Repository视图(具体怎么打开百度去,这都是基本常识了)

tips1000_2014-09-25_14-09-57

右键选择Create Remote,点OK

tips1000_2014-09-25_14-09-59

点击Change,弹出如下界面

tips1000_2014-09-25_14-09-591

URI输入之前在github上拷贝的地址,下面的内容会自动填上。你只需要再填上github上的用户名和密码即可。finish,save。

接下来的几步就简单了,在项目里面随便写点代码,然后先将新增的代码提交到本地,例如,将cat类,先add to index,然后commit。这时候,右键工程,Team->remote中就有了push选项,意味着你可以将本地代码保存在github中 了。祝贺你!

tips1000_2014-09-25_14-10-01

点击Push,点击add All Branches Spec,将本地版本库添加,然后Finish,后面一路Next,再次查看github,可以看到代码已经成功推送。

tips1000_2014-09-25_14-09-592

最后,看看我们在github上的代码吧!

tips1000_2014-09-25_14-10-00

转自博客园:http://www.cnblogs.com/ZhangWanFan/p/3993733.html

125 Responses to “ Eclipse使用git最基本流程 ”

  1. mia pron khalifa说道:

    uCcc9E This information is worth everyone as attention. When can I find out more?

  2. I really liked your blog.Really looking forward to read more. Want more.

  3. free movies说道:

    Thank you very much! I took it for myself too. Will be useful!!

  4. coloring说道:

    Ridiculous story there. What happened after? Thanks!

  5. mca money说道:

    Wow, incredible blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your site is great, as well as the content!

  6. Lung Cleanse说道:

    Way cool! Some very valid points! I appreciate you writing this write-up and the rest of the site is also very good.

  7. My Face Gifts说道:

    spain jersey home ??????30????????????????5??????????????? | ????????

  8. I really liked your post.Much thanks again. Want more.

  9. Click to read说道:

    Please let me know if you are looking for a author for your blog.

  10. more information说道:

    This is really interesting, You are a very skilled blogger. I ave joined your feed and look forward to seeking more of your wonderful post. Also, I have shared your site in my social networks!

  11. I simply could not leave your site before suggesting that I really loved the usual information an individual supply for your guests? Is gonna be back steadily in order to inspect new posts

  12. There as noticeably a bundle to find out about this. I assume you made sure nice factors in features also.

  13. This is very interesting, You are a very skilled blogger. I ave joined your feed and look forward to seeking more of your wonderful post. Also, I have shared your website in my social networks!

  14. online说道:

    You made some respectable points there. I seemed on the web for the difficulty and located most people will go together with together with your website.

  15. W88说道:

    This is a really good tip particularly to those fresh to the blogosphere. Short but very accurate info Appreciate your sharing this one. A must read article!

  16. Wow, fantastic blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your site is magnificent, let alone the content!

  17. wow, awesome blog article.Really thank you! Keep writing.

  18. Ep coc robot说道:

    Lovely blog! I am loving it!! Will be back later to read some more. I am bookmarking your feeds also.

  19. Instagram views说道:

    You made some clear points there. I looked on the internet for the subject matter and found most people will consent with your blog.

  20. Airport taxi说道:

    Your style is unique compared to other folks I ave read stuff from. Many thanks for posting when you ave got the opportunity, Guess I all just book mark this page.

  21. pretty valuable material, overall I feel this is worth a bookmark, thanks

  22. status说道:

    Very informative blog article.Really looking forward to read more. Will read on

  23. Really interesting blog, keep up the good work!

  24. The Lost Ways说道:

    Some truly prize blog posts on this site, bookmarked.

  25. PERM说道:

    Thank you for the good writeup. It in fact was a amusement account it. Look advanced to far added agreeable from you! By the way, how could we communicate?

  26. Share说道:

    Thanks-a-mundo for the blog article.Really thank you! Want more.

  27. Gretchen说道:

    Incredibly Interesting Blog site! Thank you Just for this Website!

  28. Love说道:

    We are a group of ?oluntаА аЂа•ers аА аЂаnd starting a

  29. voucher tiki说道:

    Really informative post.Really looking forward to read more. Great.

  30. wonderful points altogether, you simply gained a emblem new reader. What might you suggest about your post that you simply made a few days in the past? Any certain?

  31. here说道:

    That is a really good tip especially to those new to the blogosphere. Short but very precise information Many thanks for sharing this one. A must read post!

  32. klm promo code说道:

    You made some decent factors there. I looked on the internet for the difficulty and located most people will go together with along with your website.

  33. Thank you ever so for you post.Really thank you! Awesome.

  34. you will have an amazing weblog here! would you wish to make some invite posts on my weblog?

  35. Beyonce说道:

    There is definately a lot to find out about this issue. I really like all the points you have made.

  36. Really informative blog article.Thanks Again. Awesome.

  37. Really appreciate you sharing this blog.Thanks Again. Much obliged.

  38. I truly appreciate this article post.Really looking forward to read more. Want more.

  39. Im obliged for the blog post.Thanks Again. Fantastic.

  40. Very good article.Really thank you! Will read on

  41. This particular blog is definitely cool and factual. I have picked up many helpful stuff out of this amazing blog. I ad love to return again soon. Thanks a lot!

  42. This awesome blog is definitely awesome and diverting. I have discovered helluva handy things out of this blog. I ad love to return over and over again. Thanks a lot!

  43. Thanks for fantastic info I was searching for this info for my mission.

  44. pay day loans说道:

    The Silent Shard This will likely probably be very handy for some of the job opportunities I intend to you should not only with my blogging site but

  45. This is really interesting, You are a very skilled blogger. I ave joined your rss feed and look forward to seeking more of your great post. Also, I have shared your website in my social networks!

  46. Looking forward to reading more. Great blog.Much thanks again. Will read on

  47. There is obviously a lot to know about this. I assume you made various nice points in features also.

  48. Thanks, I ave recently been looking for info about this subject for a while and yours is the greatest I ave found out so far. However, what concerning the bottom line? Are you sure about the source?

  49. Really enjoyed this blog post.Much thanks again. Cool.

  50. Some truly choice posts on this site, saved to my bookmarks.

  51. You have done an impressive job and our entire community

  52. diet说道:

    Really appreciate you sharing this post.Really looking forward to read more. Keep writing.

  53. Ganchillo说道:

    This site was how do I say it? Relevant!! Finally I ave found something which helped me. Thank you!

  54. Wow that was odd. I just wrote an really long comment but after I clicked submit my comment didn at show up. Grrrr well I am not writing all that over again. Anyhow, just wanted to say great blog!

  55. Intriguing post reminds Yeah bookmaking this

  56. online说道:

    Wow, fantastic blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your site is wonderful, let alone the content!

  57. blue nike说道:

    recommend to my friends. I am confident they all be benefited from this site.

  58. more说道:

    My brother suggested I might like this blog. He was entirely right. This post truly made my day. You cann at imagine just how much time I had spent for this information! Thanks!

  59. Well I definitely enjoyed studying it. This post procured by you is very constructive for correct planning.

  60. You finished approximately nice points there. I did a explore taking place the deliver and found mainly guys will commend with your blog.

  61. School admission说道:

    webpage or even a weblog from start to end.

  62. Waec exam说道:

    magnificent issues altogether, you just received a new reader. What would you recommend in regards to your submit that you just made some days ago? Any certain?

  63. very nice post, i actually love this website, keep on it

  64. Modular Kitchens have changed the idea of kitchen in today as world as it has provided household women with a comfortable yet a classy area through which they could spend their quality time and space.

  65. Thank you ever so for you blog post.Much thanks again. Really Great.

  66. Thank you for your blog.Really thank you! Awesome.

  67. Thank you for your article.Really thank you! Want more.

  68. Thanks for another excellent article. Where else could anyone get that type of info in such an ideal way of writing? I have a presentation next week, and I am on the look for such information.

  69. Apple Reparatur说道:

    This is one awesome post.Thanks Again. Keep writing.

  70. Looking forward to reading more. Great article.Much thanks again.

  71. so very hard to get (as the other commenters mentioned!) organizations were able to develop a solution that just basically

  72. si ca c est pas de l infos qui tue sa race

  73. ventas说道:

    What web host are you using? Can I get your affiliate link to your host?

  74. Well, I don at know if that as going to work for me, but definitely worked for you! Excellent post!

  75. I visit every day a few web sites and websites to read articles, however this webpage presents quality based articles.

  76. entclass说道:

    Wow, great post.Much thanks again. Much obliged.

  77. One of the hair coconut oil hair growth construction and follicles.

  78. if the buffalo in my head could speak german i would not know a god damm thing. What i do know is that the language of art is out of this world.

  79. we like to honor many other world wide web websites around the internet, even if they aren

  80. happy wheels说道:

    Wow! I cant believe I have found your weblog. Very helpful information.

  81. You made some good points there. I looked on the internet for the subject matter and found most individuals will go along with with your blog.

  82. I truly appreciate this post. I have been looking everywhere for this! Thank goodness I found it on Bing. You ave made my day! Thx again

  83. Keep up the great work , I read few blog posts on this internet site and I conceive that your weblog is rattling interesting and contains lots of good info.

  84. P.S My apologies for getting off-topic but I had to ask!

  85. niw说道:

    Major thankies for the blog post.Really thank you! Really Great.

  86. There as definately a lot to find out about this issue. I like all of the points you made.

  87. Wow! This could be one particular of the most beneficial blogs We have ever arrive across on this subject. Actually Great. I am also a specialist in this topic so I can understand your hard work.

  88. to learn more说道:

    Right now it sounds like WordPress is the best blogging platform available right now. (from what I ave read) Is that what you are using on your blog?

  89. devotionals说道:

    Way cool! Some extremely valid points! I appreciate you writing this write-up and the rest of the website is also very good.

  90. check out说道:

    Wow, incredible blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your web site is great, as well as the content!

  91. this website说道:

    Major thankies for the blog.Much thanks again. Really Cool.

  92. Im grateful for the post.Thanks Again. Much obliged.

  93. for details说道:

    This article gives the light in which we can observe the reality. This is very nice one and gives in-depth information. Thanks for this nice article.

  94. Thanks for the article post.Much thanks again. Great.

  95. explore说道:

    There is noticeably a bundle to understand about this. I suppose you have made certain nice points in functions also.

  96. There as noticeably a bundle to find out about this. I assume you made sure nice factors in features also.

  97. Im grateful for the blog.Thanks Again. Really Cool.

  98. Thanks, I ave been searching for details about this subject for ages and yours is the best I ave found so far.

  99. It is actually difficult to acquire knowledgeable folks using this subject, but the truth is could be observed as did you know what you are referring to! Thanks

  100. Jet Set in Style with Esembles Collection

  101. post说道:

    Thanks so much for the blog.Really thank you! Fantastic.

  102. Share posts说道:

    we ad like work out extra techniques in this regard,

  103. You can definitely see your skills in the work you write. The world hopes for even more passionate writers like you who are not afraid to say how they believe. Always go after your heart.

  104. Tattoo Shops说道:

    Thank you for your article post.Thanks Again. Much obliged. buy viagra here

  105. miller electric说道:

    say it. You make it entertaining and you still care for to keep it smart.

  106. garage door说道:

    Thanks for the post.Really looking forward to read more. Really Cool.

  107. app说道:

    you have a fantastic blog here! would you like to create some invite posts on my blog?

  108. You are my intake , I have few web logs and rarely run out from to post.

  109. Find out more说道:

    Whoa! This blog looks just like my old one! It as on a entirely different topic but it has pretty much the same layout and design. Outstanding choice of colors!

  110. Find out more说道:

    Wow, great blog article.Really thank you! Keep writing.

  111. tiffany and co outlet Secure Document Storage Advantages | West Coast Archives

  112. click说道:

    There is obviously a lot to know about this. I think you made various good points in features also.

  113. I was able to find products and information on the best products here!

  114. I savor, lead to I discovered exactly what I was taking a look for. You ave ended my four day long hunt! God Bless you man. Have a nice day. Bye

  115. Technology News说道:

    Your style is very unique in comparison to other folks I have read stuff from. I appreciate you for posting when you ave got the opportunity, Guess I all just bookmark this site.

  116. Simply wanna say that this is very useful, Thanks for taking your time to write this.

  117. buat akun pb说道:

    You ave made some decent points there. I checked on the web for additional information about the issue and found most individuals will go along with your views on this website.

  118. My brother suggested I might like this blog. He was entirely right. This post actually made my day. You can not imagine simply how much time I had spent for this information! Thanks!

  119. you get right of entry to consistently rapidly.

  120. orlando seo说道:

    Major thankies for the article. Awesome.

  121. You might be my role designs. Thank you for the write-up

  122. sunday说道:

    Very good post.Really looking forward to read more.

  123. you will have an awesome blog here! would you prefer to make some invite posts on my blog?

  124. This rather good phrase is necessary just by the way

  125. find out more说道:

    Im thankful for the blog post.Much thanks again. Fantastic.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>