Git -- 使用笔记

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值