markdown git常用

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown git常用相关的知识,希望对你有一定的参考价值。

# Diff a file of two branches and apply to the cuurent branch
git diff **HEAD** *other_branch* -- *file_name* | git apply

# Git log for the specific commit
git show *commit*

# Add all modification/deleted changes to staged
git add -u

# Commit all modification/deleted changes without staging
git commit -a

# Show only modifications
git status -uno

# Rename a branch
git branch -m new-branch    
git branch -m old-branch new-branch

# Squash commits
git rebase -i {the previous one commit}  
git push origin +originbrach

```text
Note that --force applies to all the refs that are pushed, hence using it with push.default 
set to matching or with multiple push destinations configured with remote.*.push may 
overwrite refs other than the current branch (including local refs that are strictly behind 
their remote counterpart). To force a push to only one branch, use a + in front of the 
refspec to push (e.g git push origin +master to force a push to the master branch).
```

# Restore a file to some commit
git checkout $SHA1 `--` $FILE

> if you want revert this commit  
> git checkout $SHA1~ `--` $FILE

# Force pull to overwrite local
git fetch --all  
git reset --hard origin/$BRANCH

# Avoid the merge-commit when remote changed
get fetch  
get rebase origin/$BRANCH

以上是关于markdown git常用的主要内容,如果未能解决你的问题,请参考以下文章

markdown git的常用别名

markdown git常用

vscode 简介

markdown 工具:终端:Git:Git

markdown git #git

markdown Git笔记#git #tutorial