User-Profile-Image
hankin
  • 5
  • centos7
  • docker
  • mysql
  • PostgreSQL
  • git/gitlab
  • ELK
  • python
    • python-Tornado
    • python-django
  • redis
  • nginx
  • kvm
  • proxmox
  • mongo
  • kubernetes
  • prometheus
  • GlusterFs
  • nfs
  • freeswitch
  • httpd
  • shell脚本
  • linux
  • fastdfs
  • nextcloud
  • openssl
  • openvpn
  • rabbitmq
  • sqlite
  • svn
  • java
  • ubuntu
  • vue2
  • wordpress
  • php
  • IOT物联网
  • 项目
  • 故障处理
  • 树莓派
  • 博客存档
  • 未分类
  • 杂项
  • #1742(无标题)
  • 新视野
  • 分类
    • 项目
    • 树莓派
    • 杂项
    • 未分类
    • 新视野
    • 故障处理
    • 博客存档
    • wordpress
    • vue2
    • ubuntu
    • svn
    • sqlite
    • shell脚本
    • redis
    • rabbitmq
    • python-django
    • python
    • proxmox
    • prometheus
    • PostgreSQL
    • php
    • openvpn
    • openssl
    • nginx
    • nfs
    • nextcloud
    • mysql
    • mongo
    • linux
    • kvm
    • kubernetes
    • java
    • IOT物联网
    • httpd
    • GlusterFs
    • git/gitlab
    • freeswitch
    • fastdfs
    • ELK
    • docker
    • centos7
  • 页面
    • #1742(无标题)
  • 友链
      请到[后台->主题设置->友情链接]中设置。
Help?

Please contact us on our email for need any support

Support
    首页   ›   git/gitlab   ›   正文
git/gitlab

git-基础

2022-10-28 23:33:27
1279  0 0

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
评论 (0)

点击这里取消回复。

欢迎您 游客  

Copyright © 2025 网站备案号 : 蜀ICP备2022017747号
smarty_hankin 主题. Designed by hankin
主页
页面
  • #1742(无标题)
博主
tang.show
tang.show 管理员
linux、centos、docker 、k8s、mysql等技术相关的总结文档
210 文章 2 评论 200960 浏览
测试
测试