以下是git命令行里边的命令操作


##进入项目目录下
giscafer@Faronsince2016 /G/002_project
$ cd Comments ##查看远程分支有哪些
giscafer@Faronsince2016 /G/002_project/Comments (master)
$ git branch -a
doc
* master
remotes/origin/HEAD -> origin/master
remotes/origin/doc
remotes/origin/master ##查看本地分支有哪些
giscafer@Faronsince2016 /G/002_project/Comments (master)
$ git branch
doc
* master ##创建本地test分支
giscafer@Faronsince2016 /G/002_project/Comments (master)
$ git branch test ##查看本地分支即可见到多了test分支
giscafer@Faronsince2016 /G/002_project/Comments (master)
$ git branch
doc
* master
test ##将本地test分支推送到远程服务器
giscafer@Faronsince2016 /G/002_project/Comments (master)
$ git push origin test
Username for 'https://git.oschina.net': giscafer
Password for 'https://giscafer@git.oschina.net':
Total 0 (delta 0), reused 0 (delta 0)
To https://git.oschina.net/giscafer/Comments.git
* [new branch] test -> test ##切换到test分支
giscafer@Faronsince2016 /G/002_project/Comments (master)
$ git checkout test
Switched to branch 'test' ##添加本地需要上传的文件夹(代码文件添加方式 git add 文件.js)
giscafer@Faronsince2016 /G/002_project/Comments (test)
$ git add db ##提交信息
giscafer@Faronsince2016 /G/002_project/Comments (test)
$ git commit -m '提交数据结构表设计文档到test分支上'
[test 867e877] 提交数据结构表设计文档到test分支上
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 "db/\346\225\260\346\215\256\345\272\223\350\241\250\347\273
\223\346\236\204.docx" Warning: Your console font probably doesn't support Unicode. If you experience s
trange characters in the output, consider switching to a TrueType font such as L
ucida Console! ##上传到远程服务器
下边是报错信息(因为提交到分支需要给出--set-upstream origin <分支名>)
giscafer@Faronsince2016 /G/002_project/Comments (test)
$ git push
fatal: The current branch test has no upstream branch.
To push the current branch and set the remote as upstream, use git push --set-upstream origin test ##如下将提交推送到远程服务器
giscafer@Faronsince2016 /G/002_project/Comments (test)
$ git push --set-upstream origin test
Username for 'https://git.oschina.net': giscafer
Password for 'https://giscafer@git.oschina.net':
Counting objects: 6, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 14.90 KiB | 0 bytes/s, done.
Total 4 (delta 1), reused 0 (delta 0)
To https://git.oschina.net/giscafer/Comments.git
a7e5547..867e877 test -> test
Branch test set up to track remote branch test from origin.


##删除本地分支(提示错误是因为当初使用这test分支)
giscafer@Faronsince2016 /G/002_project/Comments (test)
$ git branch -d test
error: Cannot delete the branch 'test' which you are currently on. ##切换到其他分支
giscafer@Faronsince2016 /G/002_project/Comments (test)
$ git checkout doc
Switched to branch 'doc'
Your branch is up-to-date with 'origin/doc'. ##再次删除即可
giscafer@Faronsince2016 /G/002_project/Comments (doc)
$ git branch -d test
warning: deleting branch 'test' that has been merged to
'refs/remotes/origin/test', but not yet merged to HEAD.
Deleted branch test (was 867e877). giscafer@Faronsince2016 /G/002_project/Comments (doc)
$ git branch
* doc
master


##查看当前的origin
$ git remote -v
origin https://git.oschina.net/giscafer/Comments.git (fetch)
origin https://git.oschina.net/giscafer/Comments.git (push)


##删除远程的分支
giscafer@Faronsince2016 /G/002_project/Comments (doc)
$ git push origin :test
Username for 'https://git.oschina.net': giscafer
Password for 'https://giscafer@git.oschina.net':
To https://git.oschina.net/giscafer/Comments.git
- [deleted] test

 

git查看本地和创建分支、上传分支、提交代码到分支、删除分支等,git分支、git查看本地和创建分支以及上传分支到服务器的更多相关文章

  1. Git的基本了解与使用、向github提交代码

    #Git的基本了解与使用.向github提交代码- git:是一个版本控制系统.- github:一个代码托管提供商.开源网站.是一个面向开源及私有软件项目的托管平台,因为支持Git作为唯一的版本库格 ...

  2. Git如何fork别人的仓库并作为贡献者提交代码

    例如 要fork一份google的MLperf/inference代码,下面介绍具体做法:预备知识git里的参考有几种表示,分别是上游仓库,远程仓库和本地仓库,逻辑关系如下拉取代码的顺序:别的大牛的代 ...

  3. 2017.6.30 使用git新建项目、仓库并拉取、提交代码

    1.在码云上新建一个项目rms 2.在本地指定位置新建仓库,生成.git文件夹 3.同步远程仓库,并拉取最新代码 远程仓库默认名为orgin.可以修改,这里就是用默认名了. 注意:这里使用ssh方式的 ...

  4. idea git拉取、合并、处理冲突、提交代码具体操作

    早在两个月前我还在用eclipse开发,并且也发布的一些eclipse git的相关操作(操作都是本人亲自实践过的),但由于项目团队要求,开发工具统一用idea,实在不得已而为之切换了开发工具, 初次 ...

  5. 提交代码的其他方式,不单单只有git

    1.  xftp提交代码至服务器,直接连接服务器(如果使用可以直接到官网下载一个试用版或者家庭教育版的,本人不推荐使用破解版毕竟是直接和公司服务器对接出问题不好交代) // https://www.n ...

  6. 使用Git初始化本地仓库并首次提交代码

    本文介绍使用Git初始化本地仓库,并首次提交代码到远程仓库GitLab上面. 首先,登录GitLab,创建一个新项目的私人仓库: 然后,在本地仓库(就是你写代码文件夹),右键,Git Bash Her ...

  7. 记第一次多用户在Git提交代码

    今天第一次进行了多用户(其实就两人)在自建Git服务器提交代码. 先记录碰到的问题:首先是本地提交代码时,进行了add,commit后,在push时碰到服务器故障,待设置好服务器后,再push时,却p ...

  8. 使用git提交代码流程

    一.拉取最新代码 一般在本地进行开发时,都是切换到自己的dev分支进行开发,当开发完成需要进行代码提交,在进行代码提交前需要先进行拉取远程仓库代码,进行更新,但是此时会提示需要将本地代码进行commi ...

  9. git--新建分支&提交代码

    本地文件都删除后,本地分支也随之被删除了: 重新clone:git clone - (-为代码在git上的地址,不同协议会有不同形式的地址,例如:HTTPS.SSH,我用HTTPS) 进入克隆完成的代 ...

  10. 使用git提交代码到github,每次都要输入用户名和密码的解决方法

    自从使用git提交代码到github后,发现自己使用git的功力增长了不少,但也遇到不少问题.比如,使用git提交代码到github的时候,经常要求输入用户名和密码,类似这种: 网上有这么一种解决方法 ...

随机推荐

  1. 记录一次Quartz2D学习(五)

    (四)内主要讲了绘制状态的保存与恢复 本次主要讲述 缩放,旋转,平移等操作 5.附加操作 5.1 旋转 TIP: 旋转操作主要是对本次渲染的图层进行旋转,旋转的中心为左上角顶点 - (void)dra ...

  2. datatable和list的转换

    在开发中,把查询结果以DataTable返回很方便,但是在检索数据时又很麻烦,没有list<T>检索方便.但是数据以ILIST形式返回,就为我们在.NET中使用传统的数据绑定造成了不便.下 ...

  3. java中数据类型的转换

    数据类型的转换,分为自动转换和强制转换. 自动转换是程序执行过程中“悄然”进行的转换,不需要用户提前声明,一般是从位数低的类型向位数高的类型转换 强制转换必须在代码中声明,转换顺序不受限制 自动数据类 ...

  4. Greenplum 源码安装教程 —— 以 CentOS 平台为例

    Greenplum 源码安装教程 作者:Arthur_Qin 禾众 Greenplum 主体以及orca ( 新一代优化器 ) 的代码以可以从 Github 上下载.如果不打算查看代码,想下载编译好的 ...

  5. XP本地连接正常无法上网的解决方法

    原文: http://www.doc88.com/p-599590609730.html

  6. Microsoft Windows* SDK May 2010 或较新版本(兼容 2010 年 6 月 DirectX SDK)GPU Detect

    原文链接 下载代码样本 特性/描述 日期: 2016 年 5 月 5 日 GPU Detect 是一种简短的示例,演示了检测系统中主要显卡硬件(包括第六代智能英特尔® 酷睿™ 处理器产品家族)的方式. ...

  7. LDR、STR指令

    LDR(load register)指令将内存内容加载入通用寄存器 STR(store register)指令将寄存器内容存入内存空间中 #define GPJ0CON 0xE0200240 _sta ...

  8. [LeetCode] Nth Digit 第N位

    Find the nth digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... Note: n i ...

  9. [LeetCode] Rotate List 旋转链表

    Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1 ...

  10. 占位符行为 PlaceHolderBehavior 的实现以及使用

    这个效果我不太会描述 PlaceHolder直译占位符 也有人把这个效果叫水印效果 就是和HTML5的PlaceHolder属性一样的效果 上图直观: 使用方法: 首先下载 占位符行为dll.rar  ...