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提交到分支的更多相关文章

  1. git提交本地分支到远程分支

    git提交本地分支到远程分支   git 常用命令(含删除文件) Git常用操作命令收集: 1) 远程仓库相关命令 检出仓库:$ git clone git://github.com/jquery/j ...

  2. 关于git 提交到分支

    想必大家对于github并不陌生,但是有时候我们提交到github上的页面,想将静态的页面展示给别人看,所以这个时候,需要创建一个gh-pages的分支,然后利用 https://you github ...

  3. git,提交错了分支,想把远程的分支恢复到上一个版本

    1.先将本地分支回滚到上一个版本 2.删除远程分支(可以先备份一下) 3.创建新的分支,将本地分支push上去

  4. Git提交出现 Everything up-to-date

    出现这个问题的原因是git提交改动到缓存,要push的时候不会将本地所有的分支都push掉,所以出现这个问题.我们应该告诉git提交哪个分支.这里有种特殊的情况是如果你是fork别人的仓库再clone ...

  5. git提交项目到已存在的远程分支

    今天想提交项目到github的远程分支上,那个远程分支是之前就创建好的,而我的本地关联分支还没创建.   之前从未用github提交到远程分支过,弄了半个钟,看了几篇博文,终于折腾出来.现在把步骤整理 ...

  6. git合并别的分支某次提交或合并

    合并别的分支某次提交 master分支上改了一个bug.提交到master分支.现在在dev分支上开发,需要把master分支上改的那个bug合过来.步骤是:先在master分支上查改那个bug的SH ...

  7. 1git命令的使用,查看git仓库状态,添加文件到git跟踪,git提交,查看git分支,查看git仓库日志信息,切换git分支,解决git分支合并后出现冲突的问题

    1新建一个存储git的文件夹,命令是: toto@toto-K45VD:~$ mkdir gitfolder 2初始化一个git仓库,命令是: toto@toto-K45VD:~$cd gitfold ...

  8. git 实现提交远程分支步骤

    git clone git branch [分支名] 创建分支 git branch 查看本地所有分支 git checkout [分支名称] 切换分支 ---写代码--- git status (查 ...

  9. Git提交分支

    Git提交分支操作 1.git add 命令告诉 Git 开始对这些文件进行跟踪 git add . 2.然后提交 git commit -m'这是注释信息' 3.git pull命令用于从另一个存储 ...

随机推荐

  1. 2019/9/18 IIS服务器 ftp站安装:隔离模式

    net user ftp1  /add 添加两个账户 在d盘下创建ftp站的文件夹ftptest,进入文件夹,创建文件夹LocalUser,进入LocalUser 分别创建administrator ...

  2. zabbix的nginx监控+邮件报警

    nginx监控    下载nginx的监控模板

  3. 浙大数据结构课后习题 练习三 7-4 List Leaves (25 分)

    Given a tree, you are supposed to list all the leaves in the order of top down, and left to right. I ...

  4. trigger添加及表达式

    创建触发器 点击Configuration(配置) → Hosts(主机) 点击hosts(主机)相关行的trigger 点击右上角的创建触发器(create trigger) name : 触发器名 ...

  5. 【CF 463F】Escape Through Leaf

    题意 给你一棵 \(n\) 个点的树,每个节点有两个权值 \(a_i,b_i\). 从一个点 \(u\) 可以跳到以其为根的子树内的任意一点 \(v\)(不能跳到 \(u\) 自己),代价是 \(a_ ...

  6. string::find_first_of

    string (1) size_t find_first_of (const string& str, size_t pos = 0) const noexcept; c-string (2) ...

  7. eclipse+自己安装的maven不能run as 找不到包

    我本地环境eclipse自带maven但是默认指定的路径是c盘下,本着不想放c盘,就自己下了maven包集成到eclipse中,但是java类中main方法如果调用了maven中的包是找不到的.后类自 ...

  8. 使用vue写扫雷游戏

    上班闲来没事做,,心血来潮.想用刚学的vue,写一个扫雷游戏..好了,直入正题. 第一步,先制作一个10x10的格子图..这个divcss就不说了..大家都会. 第二步,制造一个数组,用来生成随机雷区 ...

  9. VS开发框架DevExtreme v19.1全解析!全新的UI小部件

    行业领先的.NET界面控件DevExpress 正式发布了v19.1版本,本文将以系列文章的方式为大家介绍DevExtreme Complete Subscription v19.1中全新发布的Dro ...

  10. python---wav音频

    import pyaudio #导入库 import wave #导入wav音频库 import sys from PyQt5.QtWidgets import QApplication, QWidg ...