git提交到分支
git checkout
grego@gregoo:mygo$ git checkout origin/test
Note: checking out 'origin/test'. You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example: git checkout -b <new-branch-name> HEAD is now at be427c9... Create README.md grego@gregoo:mygo$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'. grego@gregoo:mygo$ git branch
* (HEAD detached from be427c9)
master
test
grego@gregoo:mygo$ git branch -r
origin/HEAD -> origin/master
origin/master
origin/test grego@gregoo:mygo$ git push origin HEAD:test
Username for 'https://github.com': ningxin1718
Password for 'https://ningxin1718@github.com':
Counting objects: , done.
Compressing objects: % (/), done.
Writing objects: % (/), bytes | bytes/s, done.
Total (delta ), reused (delta )
To https://github.com/ningxin1718/mygo.git
be427c9..9a48c56 HEAD -> test
git log 退出 按 q
git回退
git reset --hard <版本号> // 注意使用 --hard 参数会抛弃当前工作区的修改 // 使用 --soft 参数的话会回退到之前的版本,但是保留当前工作区的修改,可以重新提交 为了覆盖掉远端的版本信息,使远端的仓库也回退到相应的版本,需要加上参数--force git push origin <分支名> --force
git操作
1. git add 添加 多余文件
这样的错误是由于, 有的时候 可能 git add . (空格+ 点) 表示当前目录所有文件,不小心就会提交其他文件 git add 如果添加了错误的文件的话 撤销操作 git status 先看一下add 中的文件
git reset HEAD 如果后面什么都不跟的话 就是上一次add 里面的全部撤销了
git reset HEAD XXX/XXX/XXX.java 就是对某个文件进行撤销了 2. git commit 错误 如果不小心 弄错了 git add后 , 又 git commit 了。
先使用
git log 查看节点
commit xxxxxxxxxxxxxxxxxxxxxxxxxx
Merge:
Author:
Date: 然后
git reset commit_id over PS:还没有 push 也就是 repo upload 的时候 git reset commit_id (回退到上一个 提交的节点 代码还是原来你修改的)
git reset –hard commit_id (回退到上一个commit节点, 代码也发生了改变,变成上一次的) 3.如果要是 提交了以后,可以使用 git revert 还原已经提交的修改
此次操作之前和之后的commit和history都会保留,并且把这次撤销作为一次最新的提交
git revert HEAD 撤销前一次 commit
git revert HEAD^ 撤销前前一次 commit
git revert commit-id (撤销指定的版本,撤销也会作为一次提交进行保存)
git revert是提交一个新的版本,将需要revert的版本的内容再反向修改回去,版本会递增,不影响之前提交的内容。
…or create a new repository on the command line
echo "# test" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/ningxin1718/test.git
git push -u origin master
…or push an existing repository from the command line
git remote add origin https://github.com/ningxin1718/test.git
git push -u origin master
…or import code from another repository
You can initialize this repository with code from a Subversion, Mercurial, or TFS project.
step1,在本地新建分支
git branch newbranch
step2:把本地分支push到远程
git push origin newbranch
step3:切换到该分支
git checkout newbranch
step4:查看本地修改
git status
step5:添加本地修改
git add .
step6:commit修改
git commit -m 'XXXX'
拉取远程分支 git fetch origin test
git checkout -b test origin/test
git提交到分支的更多相关文章
- git提交本地分支到远程分支
git提交本地分支到远程分支 git 常用命令(含删除文件) Git常用操作命令收集: 1) 远程仓库相关命令 检出仓库:$ git clone git://github.com/jquery/j ...
- 关于git 提交到分支
想必大家对于github并不陌生,但是有时候我们提交到github上的页面,想将静态的页面展示给别人看,所以这个时候,需要创建一个gh-pages的分支,然后利用 https://you github ...
- git,提交错了分支,想把远程的分支恢复到上一个版本
1.先将本地分支回滚到上一个版本 2.删除远程分支(可以先备份一下) 3.创建新的分支,将本地分支push上去
- Git提交出现 Everything up-to-date
出现这个问题的原因是git提交改动到缓存,要push的时候不会将本地所有的分支都push掉,所以出现这个问题.我们应该告诉git提交哪个分支.这里有种特殊的情况是如果你是fork别人的仓库再clone ...
- git提交项目到已存在的远程分支
今天想提交项目到github的远程分支上,那个远程分支是之前就创建好的,而我的本地关联分支还没创建. 之前从未用github提交到远程分支过,弄了半个钟,看了几篇博文,终于折腾出来.现在把步骤整理 ...
- git合并别的分支某次提交或合并
合并别的分支某次提交 master分支上改了一个bug.提交到master分支.现在在dev分支上开发,需要把master分支上改的那个bug合过来.步骤是:先在master分支上查改那个bug的SH ...
- 1git命令的使用,查看git仓库状态,添加文件到git跟踪,git提交,查看git分支,查看git仓库日志信息,切换git分支,解决git分支合并后出现冲突的问题
1新建一个存储git的文件夹,命令是: toto@toto-K45VD:~$ mkdir gitfolder 2初始化一个git仓库,命令是: toto@toto-K45VD:~$cd gitfold ...
- git 实现提交远程分支步骤
git clone git branch [分支名] 创建分支 git branch 查看本地所有分支 git checkout [分支名称] 切换分支 ---写代码--- git status (查 ...
- Git提交分支
Git提交分支操作 1.git add 命令告诉 Git 开始对这些文件进行跟踪 git add . 2.然后提交 git commit -m'这是注释信息' 3.git pull命令用于从另一个存储 ...
随机推荐
- SpringMVC基础02——HelloWorld
1.搭建环境 博主使用的环境是IDEA2017.3,首先我们需要创建一个maven项目父项目,创建一个project,选择maven,之后点击next 添写当前项目的坐标,之后点击next 填写项目名 ...
- mysql统计表中条目个数的方法举例
说明:以下标红且加大括号的均需要替换为实际待查询的表名或数据库名. [1].统计某张或某几张表的数据量: select count(*) from {TABLE_NAME}; #or select c ...
- Delphi ListBox组件
- 08ServletContext
1. 概念 代表整个web应用,可以和程序的容器(服务器)来通信 2. 获取 1. 通过request对象获取 request.getServletContext();2. 通过HttpServlet ...
- 修改phpMyAdmin 导入MySQL数据库文件大小限制
默认情况下,phpMyAdmin导入MySQL数据库文件大小为2M. 很多朋友对网站进行搬家的时候,网站数据进行导入时会出现一些问题,提示超出导入大小限制. 默认MYSQL只能导入最大2MB的数据,于 ...
- uestc summer training #9 牛客第三场 BFS计数
G.coloring tree BFS计数 题目:给你n(<=5000)个节点的一颗树 你有K(<=5000)种颜色 你可以给每一个节点染一种颜色 总共有Kn种染色方法 在一种染色方法中 ...
- CUDA升级后
打开工程文件.vcxproj,找到 <Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 10.0.props" ...
- Mongodb数据模型
描述表关系的方式: 方式一:嵌入式 > db.person.find({name:'zjf'}).pretty() { "_id" : ObjectId("592f ...
- CH5104 I-country[线性DP+分类讨论]
http://contest-hunter.org:83/contest/0x50%E3%80%8C%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92%E3%80%8D%E4%B ...
- vue的组件创建和使用
首先说一下vue组件 什么是组件? 在我的理解,vue的所有页面内容都是组件. 什么是父子组件? 因为所有的页面内容都是组件,那么怎么区分父子组件呢?其实很简单,现在有一个页面,在js里面的 comp ...