Git 初始配置
Git global setup
git config --global user.name <name>
git config --global user.email <email>
Create a new repository
git clone <clone with ssh:远程仓库地址>
cd <目录>
git switch -c master
touch README.md
git add README.md
git commit -m "add README"
git push
Push an existing folder
cd <existing_folder>
git init --initial-branch=main
git remote add origin <远程仓库地址>
git add .
git commit -m "Initial commit"
Push an existing Git repository
cd <existing_repo>
git remote rename origin old-origin
git remote add origin <远程仓库地址:git@47.104.68.90:root/reactionkinetics.git>
commit
git commit -m <“评论内容”>
ignore
- 在目录下添加.gitignore文件
- Pycharm下可右键要忽略的文件或者目录
Tag
- git tag -a 标签名称 -m “标签说明” 如:git tag -a dev-v1.1.11 -m “dev分支代码版本存储”
git checkout main
git tag -a v1.2.1.12 -m "版本号2022-8-25上线版本"
git push origin v1.2.1.12
撤销or回滚
- 查看指定文件的历史版本,不加默认全部
- 点击Q退出“log”的查看
git log <filename>
- 回滚到指定commit
git checkout <commitID> <filename>
下载查看指定分支下资源
- 下载
git clone <url>
- 下载后查看所有分支
git branch -a
- 切换分支后即可在本地查看到其他分支
git checkout <branch_name>
Questions
git中无法忽视 .idea等文件的解决
https://www.cnblogs.com/xiaoxi-jinchen/p/15020350.html
- 多人开发时,可能.idea已被追踪,需要先清除git缓存
- 记得切换到目录下
git rm -r --cached .idea