Work flow with git and github

Work with Remotes

Check the current status

  1. git status

Check the latest source on remote branch

  1. git fetch
  2. git status
  3. git log <remote>/<branch> --not <current_branch>
  4. git merge <remote>/<branch>

Add an remote Repo

  1. git remote add <shortname> <url>

Check the remote

  1. git remote -v // check all remote
  2. git remote show <remote> // show the detail status of an remote

Rename an rename

  1. git remote rename <origin> <destination>

Remove the upstream for the current branch

  1. git branch --unset-upstream

Change the remote that <branchA> is trancing

  1. git branch <branchA> -u <new_remote>/<branch>

Push the current branch as an new branch to remote

  1. git push <remote> <branch>

Push changes to another remote branch

  1. git push <new_remote>/<branch>

Work with Branches

Check branches

  1. git branch // check local branches
  2. git branch --all // check local and remote branches

Create a new branch

  1. git branch branchA // create a new branch based on the current branch
  2. git branch branchB <remote>/<branch> // create a new branch that traces <remote>/<branch>

Switch branch

  1. git checkout branchB // change the current branch to branchB

Check the mapping between local branch and remote branch

  1. git branch -vv

Rename an branch

  1. git branch -m <oldname> <newname>

Others Common Commands

Show the content of an commit

  1. git show <commit-id>
  2. git show <commit-id> --name-only

Check differences according log

  1. git log branchA --not branchB
  2. git log branchA --not branchB --name-only

Obtain the latest source under version control

  1. git checkout <file-name> // checkout the latest file under version control, and discard local changes
  2. git checkout <branchA> // switch the current branch to branchA

Commit changes

  1. git commit -m '' . // submit all tranced files under the current folder, no matter if they are git-added

Reference:

git, git-scm

[git] Git in Practice的更多相关文章

  1. error setting certificate verify locations: CAfile: E:/git/Git/mingw64/ssl/certs/ca-bundle.crt

    一.问题: 当git clone项目时报 error setting certificate verify locations: CAfile: E:/git/Git/mingw64/ssl/cert ...

  2. [git]git 分支

    什么动作,关键看你想完成什么 1. 添加新的远程分支: git push origin current_local_branch:new_remote_branch 2. 删除远程分支(冒号前必须要有 ...

  3. [git] git 的基本认知

    版本管理 ( Version Control ) 版本管理系统是一个记录文件变更的系统,让你在一段时间后可以恢复指定版本的文件.版本管理系统大致可分为三类:独立的本地版本管理系统.中心化版本管理系统. ...

  4. Git -> Can't start Git: git.exe

    问题描述 导入别人的PyCharm项目后提示:Can't start Git:git.exe 解决办法 Git就是个类似插件,在Git的官网上注册个账号然后每次编译就会自动把程序上传到网上备份.可以方 ...

  5. GIt -- git push 远程分支老是需要重新输入公钥密码问题处理?

     步骤: 先查看远程有哪些分支 删除远程分支,重新关联远程分支 最后再git push 到远程分支 git remote -v git remote rm RedisNote git remote a ...

  6. [git] git怎样fork一个repo

    描述 我定制了一下strongswan的工程.然后想把我自己的定制变成一个repo push到远端git.tong.com与大家分享. 这个时候,应该怎么做? 如果你用过github的话.那么你可以理 ...

  7. [skill][git] git 常用操作记录

    傻瓜入门: step by step : https://try.github.io/levels/1/challenges/1 一本书: https://git-scm.com/book/en/v2 ...

  8. [git]git project仓库迁移

    转自:https://segmentfault.com/q/1010000000124379 如果你想从别的 Git 托管服务那里复制一份源代码到新的 Git 托管服务器上的话,可以通过以下步骤来操作 ...

  9. can't start Git: git.exe

    can't start Git: git.exe :不能启动Git 这是因为Git的可执行文件的路径不正确,需要手动设置,. 找到设置Git的窗口 然后修改一下路径就行了 点击OK就可以了.

  10. IDEA 中 使用 git(Git)

    GitLab GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务.安装方法是参考GitLab在GitHub上的Wiki页面. Git Git( ...

随机推荐

  1. var let const的一些区别

    var let const 都是来定义变量的. var let 作用域有些区别. const 类似于java中的常量的概念.即:只能给一个变量赋值一次,即指定一个引用. 举例来说: function ...

  2. 使用 PlantUML 高效画图

    PlantUML 是一种程序员看了就会爱上的画图方式:自然,高效. 支持快速绘制: 时序图 类图 用例图 活动图 状态图 等等 安装教程 Intellij IDEA中安装 & 使用PlantU ...

  3. MapReduce之Map Join

    一 介绍 之所以存在Reduce Join,是因为在map阶段不能获取所有需要的join字段,即:同一个key对应的字段可能位于不同map中.Reduce side join是非常低效的,因为shuf ...

  4. player视频.js

    var playStatus = 'pending'; var html_a = '<div class="weui-dialog__bd" id="lly_dia ...

  5. python学习笔记~INI、REG文件读取函数(自动修复)

    引入configparser,直接read整个INI文件,再调用get即可.但需要注意的是,如果INI文件本身不太规范,就会报各种错,而这又常常不可避免的.本文自定义函数通过try...except. ...

  6. linux 下的torrent下载器qBitTorrent

    BT下载利器--Qbittorrent完全攻 Ubuntu使用命令安装qBittorrent的方法 源码下载

  7. 位域 (Bit field)

    最近开始看编程之美这本书,里面有一道关于中国象棋将帅位置的简单问题,如下图所示,写一个程序输出将.帅的合法位置. 分析与解法 问题的本身并不复杂,只要把所有A.B 互相排斥的条件列举出来就可以完成本题 ...

  8. 如何将github项目上传至gitlab

    一.修改远程分支关联 删除远程分支关联 将指向github的远程分支关联关系删除 git remote rm origin 添加新的远程分支关联 新的remote地址指向gitlab相应地址 git ...

  9. Verilog_Day3

    内容为书中第5章 条件语句 条件语句必须在过程块语句中使用.所谓过程块语句是指由 initial 和 always 语句引导的执行语句集合.除这两种块语句引导的begin_end块中可以编写条件语句外 ...

  10. 推荐 的FPGA设计经验(2)-时钟策略优化

    Optimizing Clocking Schemes Avoid using internally generated clocks (other than PLLs) wherever possi ...