Git 常用命令
来源:互联网 发布:淘宝联盟怎么注册 编辑:程序博客网 时间:2024/06/02 02:33
创建git全局配置
装载请注明出处: http://blog.csdn.net/xiaowu_zhu/article/details/78332164
git config --global user.name="xiaowujiang" git config --global user.email="xiaowu_zhu@126.com"
新建一个本地的仓库
- 项目目录—-> git init
将代码托管到网上
- 首先登陆到github或bitbucket
- 创建一个项目
git clone //从网站上克隆
https://github.com/xiaowu-zhu/cool-weather.githttps://xiaowu-zhu@bitbucket.org/xiaowu-zhu/cool-weather.git
cp -R /cool-weather/. . //将克隆的文件全部复制到项目的根目录
git add .
git commit -m “提交的内容”
git push origin master
将代码同步到本地
git pull origin master(没有git fetch安全)
git fetch
- git fetch origin master:tmp
- git diff tmp
- git merge tmp
查看分支
- git branch(本地的)
- git branch -a (远程的)
新建分支
- git checkout -b 分支名(新建分支)
删除分支
- git branch -d tmp
切换分支
- git checkout 分支名
修改提交的注释
- git commit –amend
查看提交的log
- git log
- git reflog
撤销提交
git reset --hard HEAD(头信息git reflog中可查看)
强制到远程
git push -f
修改远程仓库
方法有三种:
修改命令
git remote set-url origin [url]
例如:
Git remote set-url origin gitlab@gitlab.chumob.com:PHP/hasoffer.git
先删后加
git remote rm origingit remote add origin [url]
例如:
git remote add origin https://xiaowu_zhu@bitbucket.org/xiaowu-zhu/working.git
直接修改config文件
常见问题
Updates were rejected because the tip of your current branch is behind
方法1:
强制push(一般不可取,这样会使远程修改丢失)
git push -u origin master - f
方法2:
push前,先将远程分支pull下来
git pull origin mastergit push origin master
方法3:
若不想merge远程和本地修改,可以先创建新的分支
git branch [name]
然后push
git push -u origin [name]
更多信息请看: https://xiaowujiang.cn/blog/
阅读全文
1 0
- git 常用命令
- Git常用命令
- git 常用命令
- git 常用命令
- git 常用命令
- git 常用命令
- GIT常用命令
- git 常用命令
- git 常用命令
- Git 常用命令
- git 常用命令
- Git常用命令
- Git常用命令
- git 常用命令
- Git 常用命令
- git常用命令
- git 常用命令
- Git 常用命令
- 算法思想-深度搜索算法-leetcode相关题目总结
- Xcoode9兼容FFmmpeg
- 1024,祝所有程序员节日快乐
- eclipse运行项目可以正常运行,但是localhost:8080打不开
- 欢迎使用CSDN-markdown编辑器
- Git 常用命令
- centos7 修改yum源为阿里源
- centos6.5安装部署rabbitmq
- 区块链入门(3):在以太坊私有网络中建立节点集群,并发生交易
- 服务器-Nginx-Mac OS X 下编译安装 Nginx
- 中马“两国双园”成中企投资东盟国际产能重要平台
- 人体姿态估计数据集整理(Pose Estimation/Keypoint)
- 深度对抗学习在图像分割和超分辨率中的应用
- 区块链入门(4)Truffle创建项目,编译,及项目部署