常用命令之git/linux

1,git类

(4)更换主分支:由main改为master。(在GitHub上遇到)

git branch -m main master
git fetch origin
git branch -u origin/master master

(3)撤销commit

git reset --soft HEAD^

参考:https://www.jianshu.com/p/a9f327da3562

(2)删除远程分支:

先查看远程分支:git branch -r

使用下面两条命令来删除远程分支

git branch -r -d origin/branch-name
git push origin :branch-name

参数含义: -r, --remotes List or delete (if used with -d) the remote-tracking branches.

上面的第一句是删除了本地的远程跟踪分支( 我也不知道怎么描述更加清楚),此时使用git branch -a查看,分支remotes/origin/branch-name应该已经不存在了。

为什么还需要第二句,因为上面只是把本地的远程跟踪分支删除了,远程的分支还没有删除,所以第二句就是真正的删除原种分支。

若出现错误  重新操作  

Pushing an empty <src> allows you to delete the <dst> ref from the remote repository.

(1)git 开新分支:

想基于某一个分支切新分支:就先到该分支下,运行命令git checkout -b即可。
git checkout okexchain/branchA
git checkout -b okexchain/branchB

2,Linux类

置空一个文件: > okexchaind.log  #不能删除,因为系统不会自动创建该文件,置空是一种解决办法。

压缩命令:tar -zcvf g.tar.gz g.json

解压:tar -zxvf g.tar.gz

linux下修改.bash_profile立即生效的三种方法

. .bash_profile
source .bash_profile
exec bash --login
 
查看内核
cat /proc/version
 
查看磁盘空间
df -h
du -h --max-depth=1 dir或什么都不写
 
 
 
 
原文地址:https://www.cnblogs.com/zccst/p/13713137.html