码迷,mamicode.com
首页 > 其他好文 > 详细

git workflow常用命令

时间:2015-04-23 15:19:36      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

  1. git init
  2. git status
  3. git add readme.txt
  4. git add --all         Adds all new or modified files
  5. git commit -m"message"
  6. git add ‘*.txt‘    Add all txt file in the whole project
  7. git remote add originName https://github.com/try-git/try_git.git       :告诉git,新增一个类似于bookmark的信息,以便后面push分享
  8. git remote -v 列出所有已知的remote列表
  9. git push -u originName master  (-u tells Git to remember the parameters, so that next time we can simply run git push and Git will know what to do.)。push到remote的repository以便分享给他人(通过pull操作)
  10. git pull originName master
  11. git diff         show unstaged differences since last commit
  12. git diff HEAD
  13. git add octofamily/octodog.txt
  14. git diff --staged         view staged differences:  staged files are files we have told git that are ready to be committed
  15. git reset octofamily/octodog.txt  cancel the staged octodog.txt file
  16. git reset HEAD LICENSE     Unstage staged file for LICENSE file
  17. git checkout -- octocat.txt           retrieve latest octocat.txt and lost changes
  18. git branch clean_up           create one branch to work on
  19. git checkout clean_up     switch to the clean_up branch
  20. git rm ‘*.txt‘ 
  21. git commit -m "Remove all the cats"
  22. git checkout master            switching to master branch
  23. git merge clean_up   merge master with clean_up branch modifications
  24. git branch -d clean_up           delete the clean_up branch after finished work on that branch
  25. git push                 push all the work we finished to github 
  26. git log
  27. git commit -a -m "modify readme" 将add to stage和commit change合二为一(add changes from all tracked files: DOES NOT ADD NEW FILE(untracked)!!)
  28. git reset --soft HEAD^将最后的一个commit rollback到staging area,再做修正后,比如增加新的文件,修改已有文件,之后再做commit动作
  29. git add todo.txt; git commit --amend -m "forget the todo.txt in last commit, so amend it here"
  30. git reset --hard HEAD^;git reset --hard HEAD^^ 撤销掉最后一个/两个commit

常见workflow场景: 

Jane创建一个文件,增加该文件到staging area,提交commit变更;

Jane修改了readme.txt文件并且增加了license文件,增加这些修改到staging area,提交变更集

 

Hosted GIT repository: Github, BitBucket;

Selft Managed: Gitosis, Gitorious

git workflow常用命令

标签:

原文地址:http://www.cnblogs.com/kidsitcn/p/4450466.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!