两种使用场景
1. 从远程clone下来
1 2 3 4 5 6
| git clone git@github.com:worlds3/DCGAN.git git add . git commit -m "描述修改信息" git push origin main
|
2. 从零创建新仓库
1 2 3 4 5 6 7 8 9 10 11
| mkdir project && cd project git init touch REDME.md touch .gitignore git add . or git add <file> git commit -m "修改的描述信息" git remote add origin git@github.com:worlds3/DCGAN.git git branch -m master main git pull --rebase origin main
git push -u origin main
|
3.github建立连接
1 2 3 4
| ssh-keygen -t rsa -C 'vmerluckycat5@gmail.com' ssh -T git@github.com # 查看连接状态 git config --global user.name 'worlds3' git config --global user.email 'vmerluckycat5@gmail.com '
|
QA:
修改C盘中.ssh的config,端口改成443,会提示有风险,直接无视风险访问[手动狗头],原因好像是校园网屏蔽了22端口,我看bc实验室的端口就是22.
1 2 3
| Host github.com Hostname ssh.github.com Port 443
|
2.怎么忽略掉数据集和一些其他的ide产生缓存文件
创建.gitignore文件,把想忽略的文件夹或者文件路径放进去就不追踪了。
1 2 3 4 5 6 7 8 9 10 11 12 13
| # 可以像这样 cifar/ 1.py 实验记录.md attention.py Practice_11_Squeeze-and-Excitation.py practise_10_cifar100.py t1.py test.py .vscode/ results/ **/__pycache__/ */__pycache__/
|
其他使用命令
1.查看仓库状态
但只返回了声明了为git仓库
2.初始化为git仓库
使用init声明为git 仓库,否则其余命令都无效的,直接从github上clone下来的默认为git仓库
3.添加文件到仓库
不进行add不会被仓库认可,而git add并没有把文件上传到github仓库,而是放在一个缓冲区,然后使用commit命令给他提交。
1 2 3
| git add <file> git commit -m "附加说明信息" # 提交到本地仓库 git push origin main #提交到远程仓库
|