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命令用于从另一个存储 ...
随机推荐
- Apache官方强心剂:开源不受出口管理条例约束!
开源软件到底受不受美国政府管制?这个话题最近已经成了热点,许多业内的专业人士都对此发表了看法. 对实体清单上所列合约方的出口和再出口的限制特别适用于受出口管理条例(EAR)约束的活动和交易. [1]开 ...
- C#将html table 导出成excel实例
public void ProcessRequest (HttpContext context) { string elxStr = "<table><tbody>& ...
- puppet集群
实验目的: 由于现有的环境中,puppetmaster是单节点,客户端更新时出现了更新失败和时间较长等现象.考虑将puppetmaster做成集群的模式,解决大量客户端更新延时和单节点故 ...
- 解决supervisord启动问题
作者:StormerX链接:https://www.jianshu.com/p/d8901ce4712b来源:简书简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处. $ superv ...
- 将Excel数据读入DataGridView
OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Microsoft Excel ...
- python连接mysql操作(1)
python连接mysql操作(1) import pymysql import pymysql.cursors # 连接数据库 connect = pymysql.Connect( host='10 ...
- python 数据库插入操作
数据库插入操作 以下实例使用执行 SQL INSERT 语句向表 EMPLOYEE 插入记录: #!/usr/bin/python # -*- coding: UTF-8 -*- import MyS ...
- 插入排序,选择排序,冒泡排序等常用排序算法(java实现)
package org.webdriver.autotest.Study; import java.util.*; public class sort_examp{ public static voi ...
- HTML+CSS知识总结1
一.浏览器页面页面由结构层(html)表现层(css)行为层(js)组成 二.DOCTYPE作用是用来告知浏览器以何种模式渲染文档. 三.严格模式是指浏览器按照W3C标准解析代码,混杂模式又称怪异模式 ...
- Linux命令-文件管理(四)
Linux命令-文件管理 Linux slocate命令 Linux slocate命令查找文件或目录. slocate本身具有一个数据库,里面存放了系统中文件与目录的相关信息. 语法 slocate ...