git

1. 删除远程分支social

  git branch -d -r origin/social
  删除服务器分支:git push origin :social
 
2. 查看远程分支
git branch -a
 
3.在本地版本库中删除所有远程版本库中已不存在的分支
git remote prune

 

4.新建分支
     新建本地分支:                1> git checkout -b sign_up
     推送到远程:                    2> git push origin sign_up:sign_up
     链接本地和远程分支:    3> git branch --set-upstream sign_up origin/sign_up
 
5.合并分支
    git merge --no-ff   确保总是新生成一个提交,避免丢失曾经存在一个特性分支的历史信息,也能够方便地看出哪些提交属于同一个特性
    git merge
 
6. 文件退出暂存区,但是修改保留
  git reset --mixed
 
7. 撤销commit
  git log
  git reset --hard commit_id
 
8. 撤销操作
   根据–soft –mixed –hard,会对working tree和index和HEAD进行重置:
    git reset –mixed:此为默认方式,不带任何参数的git reset,即时这种方式,它回退到某个版本,只保留源码,回退commit和index信息
    git reset –soft:回退到某个版本,只回退了commit的信息,不会恢复到index file一级。如果还要提交,直接commit即可
    git reset –hard:彻底回退到某个版本,本地的源码也会变为上一个版本的内容
 
9.还原修改
  git checkout -- .
 
10. 查看远程关联
     git remote -v
 
11. 回滚到指定版本
git reset --hard 139dcfaa558e3276b30b6b2e5cbbb9c00bbdca96 
git push -f -u origin [分支名称]
 
12. 获取远程分支
git checkout -t origin/test
git checkout -b xcomm_zynq_4_4 origin/xcomm_zynq_4_4
 
13. 如果要从git中删除,请运行以下命令
git rm config/database.yml
git commit -a -m "Removed database.yml"
git push branch_name
 
14. git rm 命令

-n --dry-run
Don’t actually remove any file(s). Instead, just show if they exist in the index and would otherwise be removed by the command.
-r
Allow recursive removal when a leading directory name is given.
--cached
Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone.


git rm -r -n --cached "bin/" //-n:加上这个参数,执行命令时,是不会删除任何文件,而是展示此命令要删除的文件列表预览。
git rm -r --cached "bin/" //最终执行命令.
git commit -m" remove bin folder all file out of control" //提交
git push origin master //提交到远程服务器

posted on 2014-04-03 16:14  qinyan20  阅读(300)  评论(0编辑  收藏  举报