linux上git 使用方法

一、git上新建仓库

在git上新建仓库,并命名

二、本地初始化

c 复制代码
//命令行
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
//ssh查看
cd /root/.ssh/
vim rsa.pub
//复制后粘贴进git网页设置里的ssh key
//测试设置是否成功
ssh -T git@github.com
c 复制代码
//新建一个文件夹work
mkdir work
cd work
//git初始化
git init
//拉取远程仓库
git remote add 仓库名字 ssh或者http的地址(新建仓库的地址)
git fetch <remote>  //单纯拉取到本地,不合并
//转换当仓库里有的分支//不转换git提示无此master
git branch 已有分支名字

三、使用方法

c 复制代码
//新建分支ban1
git branch ban1
//切换分支ban1
git checkout ban1


//新建了文件file1,添加进暂缓区
git add file1
//将暂存区的更改提交到本地 Git 仓库
git commit  //至少要写点东西,不然同步会失败
//同步本地到远程git仓库
git push 仓库名 <branch-name>
//拉取远程到本地,并合并
git pull 仓库名 <branch-name>


//显示当前工作目录下的文件状态,包括已修改但未暂存的文件,以及已暂存但未提交的文件
git status
//查看所有未跟踪的文件
git ls-files --others --exclude-standard
相关推荐
qq_452396233 小时前
第十五篇:《UI自动化中的稳定性优化:解决flaky tests的七种武器》
运维·ui·自动化
宁静的舞者4 小时前
Git、GitHub、Codeup(云效代码仓库)详解
git·代码仓库·codeup·云效
j_xxx404_4 小时前
Linux:静态链接与动态链接深度解析
linux·运维·服务器·c++·人工智能
_只道当时是寻常4 小时前
【Codex】Ubuntu 安装 Codex CLI 并解决 Clash 代理与账号认证问题
linux·ubuntu·chatgpt
陈佬昔没带相机5 小时前
Git Worktree: AI 编程 Agent 并行开发的秘密武器
git·agent
Elastic 中国社区官方博客5 小时前
Elastic-caveman : 在不损失 Elastic 最佳效果的情况下,将 AI 响应 tokens 减少64%
大数据·运维·数据库·人工智能·elasticsearch·搜索引擎·全文检索
brucelee1865 小时前
Claude Code 安装教程(Windows / Linux / macOS)
linux·windows·macos
jsons16 小时前
给每台虚拟机设置独立控制台密码
linux·运维·服务器
嵌入式×边缘AI:打怪升级日志6 小时前
全志T113 Tina-SDK 配套工具链开发应用(从Makefile到CMake再到Autotools)
linux
嵌入式×边缘AI:打怪升级日志6 小时前
全志T113嵌入式Linux开发环境搭建(VMware + Ubuntu 18.04)详细步骤
linux·ubuntu