git简记

github创建过程简记

echo "# javaWebTset" >> README.md // Windows/linux下创建readMe文件
git init                                                //初始化git空间--》git init --bare
git add README.md                           //添加内容到缓存区
git commit -m "first commit"              //将缓存区的内容提交到工作区
git remote add origin https://github.com/iwinder/javaWebTset.git    //链接到远程仓库
git push -u origin master      //将分支更新/提交到远程仓库

当git status时存在删除的文件,需要添加 -a 执行commit命令,即:git commit -a -m "first commit ,but has deleted"  

创建分支:

git branch <分支名>

git push -u origin   <分支名>//提交分支到远程仓库

git checkout:Git的checkout有两个作用,其一是在不同的branch之间进行切换,例如'git checkout new_branch'就会切换到new_branch的分支上去;另一个功能是还原代码的作用,例如'git checkout app/model/user.rb'就会将user.rb文件从上一个已提交的版本中更新回来,未提交的内容全部会回滚

合并分支:$ git merge [name] ----将名称为[name]的分支与当前分支合并

git tag <name> 添加tag

git tag -d <name> 删除tag

更新:

 

git pull <远程主机名> <远程分支名>:<本地分支名> [--tag]

[]中为可选项

--tag 可选,用于将tag更新到远程仓库

 

删除:

使用 git rm 命令即可,有两种选择,

一种是 git rm --cached "文件路径",不删除物理文件,仅将该文件从缓存中删除;

一种是 git rm --f "文件路径",不仅将该文件从缓存中删除,还会将物理文件删除(不会回收到垃圾桶)。

-r 就是向下递归,不管有多少级目录,一并删除

-f 就是直接强行删除,不作任何提示的意思

 

 

 

 

 

 

 

 

 

 

github创建过程原始简记

…or create a new repository on the command line

 
echo "# JavaUtilZ" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/iwinder/JavaUtilZ.git
git push -u origin master

…or push an existing repository from the command line

 
git remote add origin https://github.com/iwinder/JavaUtilZ.git
git push -u origin master
posted @ 2016-04-19 22:15  windcoder  阅读(237)  评论(0编辑  收藏  举报