git使用

设置global config

bash 复制代码
git config --global user.name "username"
git config --global user.email "[email protected]"

创建一个新的repository

bash 复制代码
git clone ssh://[email protected]:222/username/git_test.git
cd git_test
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

将已有的文件上传到git

bash 复制代码
cd existing_folder
git init
git remote add origin ssh://[email protected]:222/username/git_test.git
git add .
git commit -m "Initial commit"
git push -u origin master

将已有的repository上传到git

bash 复制代码
cd existing_repo
git remote rename origin old-origin
git remote add origin ssh://[email protected]:222/username/git_test.git
git push -u origin --all
git push -u origin --tags

误删除本地.git文件夹,可以重新建立连接

bash 复制代码
git init
git remote add origin ssh://[email protected]:222/username/git_test.git
git pull origin master
git add .
git commit -m "1"
git push -u origin master

删除远程git仓库的文件/文件夹

bash 复制代码
// 删除文件
git rm --cached state_car_frame_rect.cpp 
// 删除文件夹
git rm -r --cached tmp
git commit -m "delete"
git push -u origin master

或者

  1. 进入 Projects ->Your projects
  2. 点击进入你要删除的仓库名称 -> 左侧 Settings
  3. 鼠标滚动到最下面,找到Advanced 点击 Expand
  4. 鼠标滚动到最下面,找到Remove project 点击 Remove project
  5. 在弹出的窗口中,输入并确认想要删除的仓库名称,点击 Confirm
相关推荐
关于不上作者榜就原神启动那件事31 分钟前
git版本控制学习
git·学习
Cchaofan7 小时前
Git/GitLab日常使用的命令指南来了!
git·gitlab
可乐加.糖14 小时前
项目版本管理和Git分支管理方案
java·git·目标跟踪·gitlab·敏捷流程·源代码管理
wingaso14 小时前
[经验总结]删除gitlab仓库分支报错:错误:无法推送一些引用到“http:”
linux·数据仓库·git
ice___Cpu1 天前
Git - 1( 14000 字详解 )
大数据·git·elasticsearch
范纹杉想快点毕业2 天前
以项目的方式学QT开发(一)——超详细讲解(120000多字详细讲解,涵盖qt大量知识)逐步更新!
c语言·数据结构·c++·git·qt·链表·github
qq_653644462 天前
如何查看打开的 git bash 窗口是否是管理员权限打开
开发语言·windows·git·bash
tonngw2 天前
【Mac 从 0 到 1 保姆级配置教程 12】- 安装配置万能的编辑器 VSCode 以及常用插件
git·vscode·后端·macos·开源·编辑器·github
橄榄熊2 天前
Git 常用命令详解
git
o(╥﹏╥)3 天前
绑定 SSH key(macos)
开发语言·git·学习·macos