博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用Git 作为项目管理工具开发时的方式和注意事项
阅读量:4165 次
发布时间:2019-05-26

本文共 2277 字,大约阅读时间需要 7 分钟。

1.所有新项目都要先创建 .gitignore文件 用于控制垃圾文件的提交 在有新的插件加入生成文件时记得随时更新 下面是一份相对较全的gitignore文件 

Ruby代码  
  1. # OS generated files #  
  2. ######################  
  3. .DS_Store?  
  4. ehthumbs.db  
  5. Thumbs.db  
  6.   
  7. # Config files #  
  8. ################  
  9. /config/database.yml  
  10. /config/email.yml  
  11.   
  12. # Logs and databases #  
  13. ######################  
  14. *.log  
  15. *.sql  
  16. *.sqlite  
  17. *.sqlite3  
  18. *.db  
  19. schema.rb  
  20.   
  21. # Packages #  
  22. ############  
  23. *.7z  
  24. *.dmg  
  25. *.gz  
  26. *.iso  
  27. *.jar  
  28. *.rar  
  29. *.tar  
  30. *.zip  
  31.   
  32.   
  33. # Compiled source #  
  34. ###################  
  35. *.rbc  
  36. *.com  
  37. *.class  
  38. *.dll  
  39. *.exe  
  40. *.o  
  41. *.so  
  42.   
  43. # Generated public files #  
  44. /public/dispatch.*  
  45.   
  46. # Temp files #  
  47. *~  
  48. /tmp/*  
  49. /tmp/cache/*  
  50. /tmp/sessions/*  
  51. /tmp/sockets/*  
  52. /tmp/test/*  
  53. .sass-cache  
  54. *.tmproj  
  55. /coverage  
  56. /rerun.txt  
  57.   
  58. # Gem files #  
  59. /vendor/rails  
  60. *.gem  
  61.   
  62. # Subversion files #  
  63. .svn  




2.项目新加功能或是修复bug等开发操作 都独立新建一个branch 本地保存与提交到git服务器的都应是这个branch(默认提交的是主分支 记得加参数指定分支) 原则上只有主库管理员才修改master分支。
 


3.Amend功能。 假设多次提交实际只是修改了同一个功能或是漏提交某些文件 可以用这个功能将提交合并 使得历史记录更清晰。 


4.Commit. Commit只是将修改提交至本地的库中,向服务端的库提交需要使用push 

Ruby代码  
  1. git push (remote) (branch)  


demo from pro git
 

Java代码  
  1. $ git push origin serverfix  

This is a bit of a shortcut. Git automatically expands the serverfix branchname out to refs/heads/serverfix:refs/heads/serverfix, which means, “Take my serverfix local branch and push it to update the remote’s serverfix branch.” We’ll go over the refs/heads/ part in detail in Chapter 9, but you can generally leave it off. You can also do git push origin serverfix:serverfix, which does the same thing — it says, “Take my serverfix and make it the remote’s serverfix.” You can use this format to push a local branch into a remote branch that is named differently. If you didn’t want it to be called serverfix on the remote, you could instead run git push origin serverfix:awesomebranch to push your local serverfix branch to the awesomebranch branch on the remote project. 



git中 pull 和 fetch的区别
 


Java代码  
  1. git fetch:相当于是从远程获取最新版本到本地,不会自动merge  


Java代码  
  1. git pull:相当于是从远程获取最新版本并merge到本地  



关于移除分支
 


Java代码  
  1. git branch -d/D branch_name_which_want_to_remove   

引用
-d 
Delete a branch. The branch must be fully merged in HEAD. 
-D 
Delete a branch irrespective of its merged status. 


推送指定分支
 


git push origin 7ca86f4a61ffe27037dde873c24c493767db9a18:staging 


git push origin branch_SHA:branch_name 


Remove remote branch
 


git push origin :remote_branch_name 


合并指定分支
 

git cherry-pick branch-SHA1

转载地址:http://jflxi.baihongyu.com/

你可能感兴趣的文章
培养程序员的人脉
查看>>
技术人,不要总在很初级的层面上谈管理
查看>>
CMarkup与tinyXml直接解析XML字符串
查看>>
技术人员也要注重提升软实力
查看>>
优秀程序员的十个习惯
查看>>
如何进行软件系统架构设计?
查看>>
介绍一下海量数据的处理方法
查看>>
什么是构架设计图 ?有哪些组成?
查看>>
软件系统的架构(ArchitECture)有两个要素是什么?
查看>>
什么是非侵入式设计?
查看>>
可遇见框架技术之面试问题
查看>>
系统设计类面试题
查看>>
架构师的职责都有哪些?
查看>>
看女程序员是怎么坑大师兄的, 网友: 真的惨,笑死我了!
查看>>
C/C++程序员面试基础知识(一)
查看>>
程序员提离职遭领导威胁,一线企业总监我都认识,我让你混不下去
查看>>
朝九晚六吊打互联网企业,程序员:又开始无脑吹国企了!
查看>>
网友话数万元转行程序员,但是却没人要,网友:是学历问题吗?
查看>>
程序员辞掉30W年薪接私活:6个月就能赚回30W,庆幸自己当初辞职
查看>>
马云四天三谈996被骂上热搜:抱歉,这届年轻人不好“骗”了!
查看>>