[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

 

转载于:https://www.cnblogs.com/TonyYPZhang/p/6603029.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值