git常用命令
# git 拉取指定分支
git clone -b master <URL>
# 对文件改名
git mv file_from file_to
# 查看提交历史
git log
# 查看文件修改前后不同之处
git diff <fill_name>
# 查看某个远程仓库,并显示正处于**分支
git remote show origin
# 创建分支
# git branch 命令仅仅创建一个新分支,并不会自动切换到新分支中去。
git branch <newbranchname>
# 切换分支
git checkout <branchname>
# 创建新分支的同时切换过去
git checkout -b <newbranchname>
# 删除本地分支
git branch -d <branchname>
# 修改当前分支的分支名
git branch -m new_branch_name
# 删除远程分支
git push origin --delete <branchname>
Git 的默认分支名字是 master
# 将***分支合并回 master 分支
git checkout master
git merge <branchname>
# 删除分支
git branch -d <branchname>
# 当前所有分支的一个列表
git branch
# 查看每个分支的最后一次提交
git branch -v
# 查看哪些分支已经合并到当前分支
git branch --merged
# 查看所有包含未合并工作的分支
git branch --no-merged
- git 拉取远程分支,修改后并push
# 将远程分支合并到本地分支
git pull origin <branch>
# 开始跟踪一个文件
git add <file>
git add *
# 提交更新
git commit
# commit 命令后添加 -m 选项,将提交信息与命令放在同一行
git commit -m "update"
# 将本地分支推送到 origin 服务器
git push origin <branch>
- git撤销
# git撤销文件的修改
git checkout -- <file_name>
# git 撤销 add操作
git reset HEAD #对上一次add里的所有文件进行撤销
git reset HEAD xxx/xxx.py #对某个文件进行撤销
git reset HEAD xxx/xxx/.#对某个文件夹进行撤销
- 避免每次输入密码
git config --global credential.helper cache
conda常用命令
conda create -n env_name python=3.7
# 查看环境
conda env list
conda info -e
# 进入虚拟环境
conda activate env_name
# 退出虚拟环境
conda deactivate
conda env remove -n env_name
# 更新指定的包
conda update package_name
#查看所有已经安装的包
conda list
# grep(全局正则表达式搜索) 文本搜索命令
conda list | grep tensorflow
pip list | grep tensorflow
# 删除环境
conda remove -n name(虚拟环境名称) --all
# 安装包
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
linux常用命令
# 查看文件夹包含的文件
ls
cd - # 进入上一次工作路径
cd # 进入用户主目录;
cd ~ # 进入用户主目录;
cd / # 进入根目录
cd .. # 返回上级目录(若当前目录为“/“,则执行完后还在“/";".."为上级目录的意思);
cd ../.. # 返回上两级目录;
# 查看当前路径
pwd
# 当前工作目录下创建名为 t的文件夹
mkdir t
# 在tmp目录下创建路径为 test/t1/t 的目录,若不存在,则创建
mkdir -p /tmp/test/t1/t
# 删除 test 子目录及子目录中所有档案删除
rm -rf test
# 将文件 test.log 重命名为 test1.txt
mv test.log test1.txt
# 将文件移动到根的 test3 目录中
mv log1.txt log2.txt log3.txt /test3
# 移动当前文件夹下的所有文件到上一级目录
mv * ../
## 创建文件
# 完成内容输入后按快捷键 CRTL+D 保存文件。
cat > file.txt
# touch 命令创建文件
touch file1.txt
touch file1.txt file2.txt file3.txt # 同时创建多个文件
# 合并文件
cat file1.txt file2.txt > file3.txt
chmod -R 777 file
tmux常用命令
tmux ls
tmux new -s <name>
# 重接会话
tmux attach -t <name>
# 分离会话
tmux detach -s <name>
# 彻底关闭某个会话
tmux kill-session -t <name>
# 切换会话
tmux switch -t <session-name>
# tmux进入历史输出信息查看模式
ctrl + b,松开后再按下 [
其他命令
# 查看GPU资源
nvidia-smi
# 将自己写的包的ROOT路径加入sys.path
import os
import sys
sys.path.append(os.getcwd())