zoukankan      html  css  js  c++  java
  • [git] Git in Practice

    Work flow with git and github

    Work with Remotes 

    Check the current status

    git status

    Check the latest source on remote branch

    git fetch
    git status
    git log <remote>/<branch> --not <current_branch>
    git merge <remote>/<branch>

     Add an remote Repo

    git remote add <shortname> <url>

    Check the remote

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

    Rename an rename

    git remote rename <origin> <destination>

    Remove the upstream for the current branch

    git branch --unset-upstream

    Change the remote that <branchA> is trancing

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

    Push the current branch as an new branch to remote 

    git push <remote> <branch>

    Push changes to another remote branch

    git push <new_remote>/<branch>

    Work with Branches

    Check branches

    git branch // check local branches
    git branch --all    // check local and remote branches

    Create a new branch

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

    Switch branch

    git checkout branchB    // change the current branch to branchB

    Check the mapping between local branch and remote branch

    git branch -vv

    Rename an branch

    git branch -m <oldname> <newname>

    Others Common Commands

    Show the content of an commit

    git show <commit-id>
    git show <commit-id> --name-only

    Check differences according log

    git log branchA --not branchB
    git log branchA --not branchB --name-only

    Obtain the latest source under version control

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

    Commit changes

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

    Reference:

    git, git-scm

  • 相关阅读:
    1."问吧APP"客户需求调查分析
    “软件工程”课程的学习目标
    范式
    知乎:有哪些让你相见恨晚的 PPT 制作技术或知识?
    前端指南
    在网页中JS函数自动执行常用三种方法
    index的用法
    搜索引擎的正确姿势
    display与visibility
    bootstrap之模态框
  • 原文地址:https://www.cnblogs.com/TonyYPZhang/p/6603029.html
Copyright © 2011-2022 走看看