git使用

设置global config

bash 复制代码
git config --global user.name "username"
git config --global user.email "username@email.com"

创建一个新的repository

bash 复制代码
git clone ssh://git@172.17.1.10: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://git@172.17.1.10: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://git@172.17.1.10:222/username/git_test.git
git push -u origin --all
git push -u origin --tags

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

bash 复制代码
git init
git remote add origin ssh://git@172.17.1.10: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
相关推荐
charlee4440 分钟前
Git使用经验总结8-Git仓库历史记录清除
git·powershell·敏感信息·仓库重置·历史重写
正经教主2 小时前
【Git】Git05-04:Github分支管理与协作流程
git·github
sean9084 小时前
git filter-repo(优秀的 git repo 历史重写工具) 实战
git·repo·工具
hen3y4 小时前
清理 Git 代码库大文件历史记录
运维·git
小Lu的开源日常4 小时前
踩坑日记:为什么Git 突然 Push 不上去了
git·ssh·github
LZ7工作室5 小时前
MAC编程:在MACOS安装和使用 Git 的方法
网络·git·macos·github·个人开发
T***16078 小时前
Git增强现实案例
git·ar
Arva .9 小时前
git常用
git
久莜9 小时前
【Git】使用教程
git
果子火火10 小时前
Git clone couldn‘t connect to server
git