Some best practices for the Git

来源:互联网 发布:dbaccess declare sql 编辑:程序博客网 时间:2024/05/20 19:18

Git best practices:

  • Do read about git
  • Always keep develop branch clean
  • Always sync the develop branch (This can avoid lots of conflicts when try to dcommit to remote repository).
  • Don’t write any code directly in develop branch (The develop branch is not used to design any new functionality, it is used to sync with the remote repository. Each functionality should only be carried on the feature branch.)
  • Using git flow to create feature branch for each function development (Git flow has supplied a branching model and a set of convenience commands according to the branching model).
  • Docommit early and often in the feature branch (The code will be protected by theGit in the local repository).
  • Small, logical commits (Easy to track each commit’s modification).
  • Always review code before committing it
  • Using eg squash to merge all the small commits to one commit (That will make each commit in SVN to be a full functionality commit, and the history of the commits in SVN will not be fragmented).
  • Make all the commits to the SVN as a full functionality commit.
  • Make your Git sandbox your own (Some unfamiliar commands in Git should be tested in the sandbox first before executed in the development environment).
  • Do experiment, keep the trouble away from you
  • KISS -- Keep it simple and stupid
  • Do not use reset (--hard || -merge) without committing/stashing (Otherwise, the modification will be lost forever).
  • Do not rewrite public history: you can’t do it in git-svn. Lucky!!!
  • Do remember to call “git stash” when try to start a new feature branch.
  • Do remember to apply which stash in the feature branch where it saved.

Those practices are  abstracted from the practices from git-svn in a real project, but lots of the practices are still applied for the git-git workflow.

0 0
原创粉丝点击