以下是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. 看看C# 6.0中那些语法糖都干了些什么(终结篇)

    终于写到终结篇了,整个人像在梦游一样,说完这一篇我得继续写我的js系列啦. 一:带索引的对象初始化器 还是按照江湖老规矩,先扒开看看到底是个什么玩意. 1 static void Main(strin ...

  2. yii2分页扩展之实现跳转到具体某页

    作者:白狼 出处:http://www.manks.top/yii2_linkpager_widget.html 本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文 ...

  3. 原创:jar的名字可能影响maven的依赖下载

    自己定义了phoenix4.6-client的依赖关系POM,如下: <project xmlns="http://maven.apache.org/POM/4.0.0" x ...

  4. SQL Server 2012 新特性:包含数据库访问数据库引擎

    简单的说就是可以让包含用户访问其他数据库,那么来看看如何配置,并且验证一下:   USE test CREATE USER up1 WITH PASSWORD = 'zhuzhu' SELECT *  ...

  5. SQL Server查询第31到40条数据

    大致分为两种情况:ID连续和ID不连续. 1.ID连续的情况: 2.ID不连续的情况: (1).两次对表查询,效率较低. ID from A) (2).外层查询没有对表A进行查询,效率提高. ID f ...

  6. [Android] 怎么在应用中实现密码隐藏?

    [Android] 怎么在应用中实现密码隐藏? 在安卓应用中,用户注册或者登录时,需要把密码隐藏,实现一定的保密效果.在安卓中,可以通过设置EditText组件的TransformationMetho ...

  7. 无法解析指定对象的 TargetProperty (UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)“的异常解决

    最近在写动画的时候做一个倒计时的效果,就是数字从大到小的一个动画,但是当我设置要new PropertyPath("XXXXXXX")的时候却报了标题的异常,各种报错.百度了好久也 ...

  8. Unity UGUI知识点

    1.Canvas 属性:Screen Space Overlay -画布随屏幕大小改变而改变,面板不会被其他控件挡住 Screen Space camera 面板能被其他控件挡住 world spac ...

  9. 制作Mac安装盘U盘

    1. 下载对应版本的mac安装文件, 复制到mac上, 解压后应该是一个类似于 Install OS X [version name].app 的目录, 复制到/Applications 2. 将U盘 ...

  10. Sqlite3常用的插入方法及性能测试

    最近做到的项目涉及一个大数据量缓存重传,其中要用到的sqlite技术,把自己的学习心得整理了一下. SQLite,是一款轻型的数据库,是遵守ACID的关系型数据库管理系统,它包含在一个相对小的C库中. ...