使用Git 作为项目管理工具开发时的方式和注意事项
2012-08-30 09:01
941 查看
http://enn.iteye.com/blog/784448
1.所有新项目都要先创建 .gitignore文件 用于控制垃圾文件的提交 在有新的插件加入生成文件时记得随时更新 下面是一份相对较全的gitignore文件
Ruby代码
# OS generated files #
######################
.DS_Store?
ehthumbs.db
Thumbs.db
# Config files #
################
/config/database.yml
/config/email.yml
# Logs and databases #
######################
*.log
*.sql
*.sqlite
*.sqlite3
*.db
schema.rb
# Packages #
############
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Compiled source #
###################
*.rbc
*.com
*.class
*.dll
*.exe
*.o
*.so
# Generated public files #
/public/dispatch.*
# Temp files #
*~
/tmp/*
/tmp/cache/*
/tmp/sessions/*
/tmp/sockets/*
/tmp/test/*
.sass-cache
*.tmproj
/coverage
/rerun.txt
# Gem files #
/vendor/rails
*.gem
# Subversion files #
.svn
2.项目新加功能或是修复bug等开发操作 都独立新建一个branch 本地保存与提交到git服务器的都应是这个branch(默认提交的是主分支 记得加参数指定分支) 原则上只有主库管理员才修改master分支。
3.Amend功能。 假设多次提交实际只是修改了同一个功能或是漏提交某些文件 可以用这个功能将提交合并 使得历史记录更清晰。
4.Commit. Commit只是将修改提交至本地的库中,向服务端的库提交需要使用push
Ruby代码
git push (remote) (branch)
demo from pro git
Java代码
$ 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代码
git fetch:相当于是从远程获取最新版本到本地,不会自动merge
Java代码
git pull:相当于是从远程获取最新版本并merge到本地
关于移除分支
Java代码
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
1.所有新项目都要先创建 .gitignore文件 用于控制垃圾文件的提交 在有新的插件加入生成文件时记得随时更新 下面是一份相对较全的gitignore文件
Ruby代码
# OS generated files #
######################
.DS_Store?
ehthumbs.db
Thumbs.db
# Config files #
################
/config/database.yml
/config/email.yml
# Logs and databases #
######################
*.log
*.sql
*.sqlite
*.sqlite3
*.db
schema.rb
# Packages #
############
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
# Compiled source #
###################
*.rbc
*.com
*.class
*.dll
*.exe
*.o
*.so
# Generated public files #
/public/dispatch.*
# Temp files #
*~
/tmp/*
/tmp/cache/*
/tmp/sessions/*
/tmp/sockets/*
/tmp/test/*
.sass-cache
*.tmproj
/coverage
/rerun.txt
# Gem files #
/vendor/rails
*.gem
# Subversion files #
.svn
2.项目新加功能或是修复bug等开发操作 都独立新建一个branch 本地保存与提交到git服务器的都应是这个branch(默认提交的是主分支 记得加参数指定分支) 原则上只有主库管理员才修改master分支。
3.Amend功能。 假设多次提交实际只是修改了同一个功能或是漏提交某些文件 可以用这个功能将提交合并 使得历史记录更清晰。
4.Commit. Commit只是将修改提交至本地的库中,向服务端的库提交需要使用push
Ruby代码
git push (remote) (branch)
demo from pro git
Java代码
$ 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代码
git fetch:相当于是从远程获取最新版本到本地,不会自动merge
Java代码
git pull:相当于是从远程获取最新版本并merge到本地
关于移除分支
Java代码
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
相关文章推荐
- 使用Git 作为项目管理工具开发时的方式和注意事项
- iOS:使用Github托管自己本地的项目代码方式一:(Xcode方式:开发工具Xcode配置Git,由Xcode-->Source Control-->Commit)
- 使用Jenkins启动maven作为项目构建管理工具的web项目
- 在项目开发中使用Git版本号控制工具以提高效率
- vue项目使用cli手脚架搭建的时候要开发的步骤和注意事项
- 推荐使用Git作为管理版本工具
- 使用Eclipse进行Java Web项目开发注意事项-Tomcat配置
- 使用Jenkins启动maven作为项目构建管理工具的web项目
- 简单讲解gitblit的使用---项目多人开发代码管理工具
- IDEA中使用自带GIT工具时SSHKEY免登陆及注意事项
- 一步一步学习嵌入式Linux开发-C3-使用git管理项目2
- iOS开发-开源类库工具Cocoapods使用注意事项及错误解决办法
- 使用Jenkins启动maven作为项目构建管理工具的web项目
- 项目管理---git----快速使用git笔记(六)------本地开发与远程仓库的交互----常用git命令
- 使用Jenkins启动maven作为项目构建管理工具的web项目
- 在VS下使用 GitFlow管理项目开发
- CocoaPods还算完整的教程(安装、使用、项目管理、注意事项)
- [转]多操作系统平台协同开发时 GIT 的注意事项: 不同操作系统中的换行符(不要使用git的换行符自动转换功能,并且,尽可能保证代码的换行符都是unix); 避免使用第三方插件(如 EGit );
- 使用pycharm开发多个django项目注意事项
- [iOS]git管理工具Sourcetree使用之提交项目到远程仓库(傻瓜式图文教程)