Git入门
2015-12-08 14:34
323 查看
1、初识GIT
1.了解系统环境变量/etc/gitconfig
.gitconfig
2.设置身份
git
4000
config --help [查看config帮助]
git config --global user.name "xdy" [建一个全局的用户名]
git config --global user.email xdy@126.com [创建邮箱]
3.设置编辑器(可选)
$ git config --global core.editor emacs
4.设置你的比较工具(可选)
$git config --global merge.tool vimdiff
5.检查你的配置(可选)
$ git config --list
6.帮助
$git help <verb>
$git <verb> --help
2、常用命令
2.1、远程下载
mkdir gittest1cd gittest1
git init
远程下载:git clone git://github.com/git/hello-world.git
查看远程仓库的地址:git remote -v
2.2、添加文件
cd hello-worldecho "hello world" >> helloworld.txt
ls *.txt
git status[查看状态]
git add helloworld.txt 【添加文件】
git commit helloworld.txt -m "init helloworld" [提交并添加日志]
2.3、忽略文件
echo "bin" > bin.dllls bin*
echo "bin.dll" > .gitignore
cat .gitignore
git add .
git commit -a -m "submit bin"
2.4、查看文件的区别
git diffgit diff --staged 比较workspace VS staged
git diff --cached 比较staged VS local repo
2.5、删除文件
git rm bin1.dll 删除文件删除文件后找回文件办法:
git rm bin1.dll
ls *.dll
git reset HEAD bin1.dll
git checkout -- bin1.dll
ls *.dll
删除后提交 git commit -a -m "delete bin1.dll"
git log 查看日志
git whatchanged 查看发生了哪些改变
3、共享及更新项目
git remote 列出远程仓库git fetch origin(从远程下载,不跟主版本合并,建立一个分支)
git pull origin(自动合并)
git push origin master (master是本地的分)
git branch :列出分支
git format-patch origin/master:打补丁
4、分支的管理
git branch 分支名字:建立分支例如,建立一个名叫xdy的分支,命令为:git branch xdy
git checkout 分支名字:切换到分支上
合并merge
git merge “merge branch1 to master” HEAD branch1
另一种做法:
git checkout master
git pull .branch1
git tag -a Beta1 -m “make beta1” :发布新版本
git tag Beta1:切换回去Beta1
5、Git与SVN的对比
5.1、SVN与Git在概念和特性上的区别
5.2、SVN与Git在操作上的区别
相关文章推荐
- react-native源码分析系列一
- JavaScript concat() 方法
- poj 3320 Jessica's Reading Problem(尺取法)
- favicon的制作
- iOS 应用和游戏加速审核(插队)服务。
- Linux性能分析的前60000毫秒
- java amr格式转mp3格式(完美解决Linux下转换0K问题)
- pycharm 4.5.3 如何调整字体大小?
- Java内存与垃圾回收调优
- OC-010.OC类中的修饰可见性的关键字@private、@protected、@public
- FlexSlider插件的详细参数设置 附下载地址
- Crazepony开源四轴飞行器
- iDB是如何运转的 一
- UIScreen的 bound、frame、scale属性
- 如何确定Kafka的分区数、key和consumer线程数、以及不消费问题解决
- adump 目录,文件数狂涨
- 怎么解决tomcat占用8080端口问题图文教程
- 对话框间的消息响应
- 利用n和nvm管理Node的版本
- java cmd常用命令