git基本操作(fetch,pull,分支使用,初始化项目,恢复)
来源:互联网 发布:淘宝买家怎么延长收货 编辑:程序博客网 时间:2024/05/16 10:45
- 新用户操作:
- ssh-keygen -t rsa
- git clone git@172.16.***.***:Apptest.git
- git fetch 和git pull的区别:都是从远程的分支获取最新的版本到本地的命令
- git fetch:相当于从远程获取最新版本到本地,不会自动merge
- git fetch origin master //从远程的origin的master主分支下载最新的版本到origin/master分支上
- git log -p master..origin/master // 比较本地的master分支和origin/master分支的差别
- git merge origin/master //进行合并
- git pull:相当于从远程获取最新版本并merge到本地
- git pull origin master //相当于git fetch 和 git merge
- 实际使用中,git fetch 更安全,因为merge前,可以查看更新情况,然后决定是否合并
- git fetch:相当于从远程获取最新版本到本地,不会自动merge
- git 分支的使用:
- 本地:
- 查看:
- 本地:git branch //列出所有已存在的分支
- 远程:git branch -r
- 创建:
- git branch branchName //创建分支:branchName ,留着当前分支
- git checkout -b branchName //创建分支:branchName ,并切换到新分支
- 提交:
- git commit -am "my new branch"
- git push orgin branchName:branchName
- git push origin branchName :master //如果想把本地的某个分支mybranch提交到远程仓库,并作为远程仓库的master分支
- 切换:git checkout branchName //切换分支到3w_apptest。git commit -a //在分支上提交工作
- 删除:
- git branch -d branchName //-D是强制删除 ,本地
- git push origin :branchName
- 合并:git merge branchName //合并分支到主干道
- 标记tag
- git tag tagContent //对当前分支打tag
- git push origin branchName:branchName //然后普适到远程分支
- 查看:
- 远程:
- git branch -r
- git push origin
- 本地:
- git提交一个初始项目:
- git init
- git add .
- git commit -am "commit"
- git remote add origin git@serverip:programName.git
- git push origin master //遇到报错:提示已经存在(因为之前提交add过一次),解决:git remote rm origin
- git 提交一个文件和更新一个文件:
- 提交一个文件:
- git diff //查看被修改过的文件
- git add com/meizu/tools/tool.py
- git commit -am "test"
- git push origin master
- 更新一个文件:
- git diff
- git fetch
- git fetch
- git checkout origin/master com/meizu/tools/tool.py
- 提交一个文件:
- git 恢复
- 恢复本地被删除文件(修改没有commit):
- git checkout -f //已commit的文件不能恢复
- git 代码库退回(修改已被commit):
- 本地库退回 :
- git reset --hard commit-id //回滚commit-id,commit-id之后提交的commit都去除
- git reset --hard HEAD~3 //将最近3次的提交回滚
- 远程库退回 :
- 本地库退回 :
- 恢复本地被删除文件(修改没有commit):
0 0
- git基本操作(fetch,pull,分支使用,初始化项目,恢复)
- Git指南(2) - git基本操作和fetch, pull区别
- Git分支 and Pull&Fetch&Merge
- git入门(3)-Git pull和git fetch从远程拉取分支到本地
- git---基本操作、新建分支,合并分支branch到主干master ,git pull ,git push
- git fetch与git pull使用经验
- Git fetch、git pull
- Git 从入门到精通(从远程分支获取最新版本git fetch与git pull)(二)
- git分支基本操作
- git fetch 和 pull
- git fetch 和pull
- git fetch & pull
- 【git】pull、fetch 区别
- git 使用(9)git pull和git fetch、git reset 和 git revert 的区别用法
- git fetch 和git pull
- git fetch VS git pull
- Git fetch VS git pull
- Git fetch VS git pull
- 服务类
- bzoj1412
- PDE2 three fundamental examples
- 提交新版本到服务器的流程
- SDAU 课程练习 1016
- git基本操作(fetch,pull,分支使用,初始化项目,恢复)
- 下拉刷新 采用第三方框架pulltorefresh
- iBatis 代码自动生成工具 iBator
- Golang 中的格式化输入输出
- Android常用工具类DateUtils(二)
- sklearn-基础使用
- Combination Lock ---线段树
- iOS开发-UIScrollView详解
- 套接字编程简介