发表于: 2016-10-19 21:38:35
0 1737
今天完成的事情:看一波git
明天计划的事情:你不知道js。。
遇到的问题:网络。。各种丢包 npm下东西各种错误
收获:git的注意事项
用户信息
1
2
$ git config --global user.name "John Doe"$ git config --global user.email johndoe@example.com
文本编辑器
1
$ git config --global core.editor emacs
差异分析工具
1
$ git config --global merge.tool vimdiff
查看配置信息
1
$ git config --list
git基本
从当前目录初始化
1
$ git init
从现有仓库克隆
1
$ git clone git://github.com/schacon/grit.git
检查当前文件状态
1
$ git status
跟踪新文件
1
$ git add README
忽略某些文件
1
2
3
$ cat .gitignore
*.[oa]
*~
提交更新(-m可以直接加上信息)
1
$ git commit -m
跳过使用暂存区域
1
$ git commit -a -m 'added new benchmarks'
移除文件(先手动删除再运行命令)
1
$ git rm grit.gemspec
要移除跟踪但不删除文件
1
$ git rm --cached readme.txt
移动文件
1
$ git mv file_from file_to
查看提交历史
1
$ git log
修改最后一次提交
1
$ git commit --amend
取消已经暂存的文件
1
$ git reset HEAD benchmarks.rb
取消对文件的修改
1
$ git checkout -- benchmarks.rb
查看当前的远程库
1
git remote -v
添加远程仓库
1
$ git remote add pb git://github.com/paulboone/ticgit.git
从远程仓库抓取数据(拉取下来并不能直接修改,需要在本地新建一个分支操作)
1
$ git pull
推送数据到远程仓库
1
$ git push origin master
查看远程仓库信息
1
$ git remote show origin
远程仓库的删除
1
$ git remote rm paul
远程仓库的重命名
1
$ git remote rename pb paul
打标签
1
$ git tag -a v1.4 -m 'my version 1.4'
在当前commit 对象上新建一个分支指针(加-b 直接切换到那个分支)
1
$ git branch testing
转换到新建的分支
1
$ git checkout testing
将其他分支覆盖到当前分支
1
$ git merge hotfix
删除分支
1
$ git branch -d hotfix
查看哪些分支已被并入当前分支
1
$ git branch --merged
如果你有个叫serverfix 的分支需要和他人一起开发,可以运行git push (远程仓库名) (分支名):
1
$ git push origin serverfix
在服务器上删除serverfix 分支(git push [远程名] :[分支名])
1
$ git push origin :serverfix
将当前的工作内容衍合到目标分支,即将当前的修改在目标上重演一边(衍合后需要切到目标分支进行一次快进操作)
1
$ git rebase master
对于已经commit过后的文件,希望再通过ignore文件忽略时,使用:
1
$git update-index --assume-unchanged
行尾换行符的问题,windows下默认是\r\n,linux下是\n。
1
2
3
$git config --global core.autocrlf true // 表示自动更换crlf,windows下如果checkout是\n,则自动换为\r\n,在提交时在自动换回\n$git config --global core.autocrlf input // 自动把\r\n换为\n$git config --global core.autocrlf false // 就是不作处理
评论