git
git上手:拉取-修改-同步
gitee新建仓库并设置read.me
本地创建并进去文件夹
git init
#初始化
git remote add t1 https://gitee.com/xx/tornado1.git
#使用remote指令添加远程数据库。在<name>处输入远程数据库名称,在<url>处指定远程数据库的URL。
git pull t1 master
#省略数据库名称的话,会在名为origin的数据库进行
vi a.txt
git add a.txt
git commit -m "xxx"
git push t1 master
管理win10上的git账户
控制面板\用户帐户\凭据管理器\编辑普通凭据
从克隆的本地数据库进行推送
git clone https://gitee.com/xx/tornado1.git /root
#克隆
git push
#在克隆的数据库目录执行推送时,您可以省略数据库和分支名称
分支
git branch fz2
创建分支 fz2
git branch
不指定参数直接执行branch命令的话,可以显示分支列表。 前面有*的就是现在的分支。
git checkout fz2
切换到fz2分支
git checkout -b fz3
-b选项执行,可以创建分支并进行切换。
常用命令
git log --graph --oneline
以文本形式显示更新记录的流程图。指定--oneline选项,能在一行中显示提交的信息
可参考https://www.itqaq.com/index/262.html
排除文件
.gitignore 排除不想提交的文件
参考https://blog.csdn.net/weixin_45318845/article/details/120740012
故障处理
提示warning: in the working copy of 'a.txt', LF will be replaced by CRLF the next time Git touches it
解决git config --global core.autocrlf false
#提交时转换为LF,检出时转换为CRLF:
参考https://blog.csdn.net/weixin_55252589/article/details/129017650
其他——————————————————————————————————————————
推送到github远端仓库
环境:
已经从远端仓库拉取了初始代码
新建一个文件并推送
echo 111>abc.txt
git add .
git commit -m "test add"
git push -u origin main
网页访问仓库查看
......
示例
克隆-修改-提交到新分支
git clone xx
vim xxxx
git checkout -b fz3
git push origin fz3
杂项临时记录
Git 全局设置
git config --global user.name "Administrator"
git config --global user.email "admin@example.com"
创建一个新仓库
git clone http://12984e927c89/root/test111.git
cd test111
git switch -c main
touch README.md
git add README.md
git commit -m "add README"
git push -u origin main
推送现有文件夹
cd existing_folder
git init --initial-branch=main
git remote add origin http://12984e927c89/root/test111.git
git add .
git commit -m "Initial commit"
git push -u origin main
推送现有的 Git 仓库
cd existing_repo
git remote rename origin old-origin
git remote add origin http://12984e927c89/root/test111.git
git push -u origin --all
git push -u origin --tags