best2018的gravatar头像
best2018 2018-12-10 09:20:09
Git札记(一)

创建本地仓库 —— git init
本地仓库关联远程仓库——git remote add origin
添加文件到git仓库 —— git add xxx
提交文件到git仓库 —— git commit -m "commit desc"
本地仓库推送到远程 —— git push -u origin master
加上-u会把本地master和远程master关联起来,以后push就不用加-u
提交local master到remote master —— git push origin master:master

分支
创建xxx分支 —— git branch xxx
列出所有分支 —— git branch -a
切换到xxx分支 —— git checkout xxx
删除分支 —— git branch -d xxx
提交本地分支xxx到远程分支xxx,远程分支xxx不存在则创建 —— git push origin xxx:xxx
分支合并
当前分支合并xxx分支 —— git merge xxx

tag
查看所有tag —— git tag
创建一个tag —— git tag -a tagname -m "note"
将本地tag推送到远程 —— git push origin tagname
删除tag —— git tag -d tagname
删除远程tag —— git push origin :tagname
获取指定tag代码 —— git checkout tagname

冲突解决
先将本地修改存储起来 —— git stash
pull内容 —— git pull
还原暂存的内容 —— git stash pop stash@{0}
经历上面3个过程之后,解决冲突即可

git常见报错
There is no tracking information for the current branch
本地分支和远程分支还没关联起来,pull的时候需要指定分支

git pull origin master
-------------------------------------

从 coding.net 下载项目执行命令顺序
创建本地库文件,Git Bash Here
git init
git remote add origin URL
git commit -m "description for this commit"
git add
git clone


打赏
最近浏览
最代码官方  LV167 2018年12月11日
best2018  LV46 2018年12月11日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友