当前位置:首页 > 编程开发 > 正文内容

git学习笔记

Codefans2年前 (2023-07-10)编程开发1141

1.删除本地文件同步到仓库

Bash
git rm demo.txt
git commit -m 'remove'
git push origin master

2.拉取远程仓库

Bash
如果是第一次下载代码,
git clone https://github.com/Mogul5306/dbhot.git
或者使用命令git clone -b 分支名 远程仓库的http地址,克隆远程分支;
如果是已经下载过,只是在分支上进行过修改,现在想继续修改,需要更新dev分支
git pull -u origin dev

3.创建分支

Bash
git branch dev

4.合并分支

切换到主分支,然后再合并

Bash
git checkout master
git merge dev

5.删除分支

Bash
git branch -d bug

6.提交修改

Bash
git add . 或git add demo.txt
git commit -m "版本介绍"
git push origin dev

7.回滚

Bash
git reset --hard ID


git init: 在当前目录初始化一个新的 Git 仓库。

Bash
git init

git clone <repository>: 克隆(下载)一个远程仓库到本地。

Bash
git clone https://github.com/example/repository.git

git add <file>: 将文件添加到暂存区。

Bash
git add filename.txt

git commit -m "<message>": 提交暂存区的文件到本地仓库,并附上提交信息。

Bash
git commit -m "Add new feature"

git status: 查看工作区和暂存区的状态。

Bash
git status

git log: 查看提交历史记录。

Bash
git log

git branch: 显示所有分支,当前分支会被标记为 *。

Bash
git branch

git checkout <branch>: 切换到指定分支。

Bash
git checkout develop

git merge <branch>: 将指定分支合并到当前分支。

Bash
git merge feature_branch

git push: 将本地仓库的修改推送到远程仓库。

Bash
git push origin master

git pull: 从远程仓库获取最新的修改并合并到本地仓库。

Bash
git pull origin master

git remote add <name> <url>: 添加一个远程仓库。

Bash
git remote add origin https://github.com/example/repository.git

git remote -v: 查看远程仓库的详细信息。

Bash
git remote -v

git diff: 查看工作区和暂存区的差异。

Bash
git diff

git reset <file>: 将文件在暂存区中的修改撤销。

Bash
git reset filename.txt

git清除工作区缓存

Bash
git rm --cached repository

这些是常用的 Git 命令和示例,可以帮助你进行常规的版本控制操作。记住,Git 有很多其他功能和选项,你可以参考官方文档或其他资源来深入学习 Git。

扫描二维码推送至手机访问。

版权声明:本文由图慧网发布,如需转载请注明出处。

本文链接:http://www.tuh8.com/?id=73

分享给朋友:

“git学习笔记” 的相关文章

饥荒控制台全物品直接制造代码 饥荒刷怪刷boss代码

饥荒控制台全物品直接制造代码 饥荒刷怪刷boss代码

饥荒-控制台操作说明(包含全物品直接制造、开小地图、加血上限、物品添加等) 操作起来真的很简单的,请详细看完哦!使用说明:1. 游戏中按 “~”键 开启控制台,输入内容按回车键,字幕会全部消失 (或者这里按下Ctrl+L就可以去除那些残留的字幕了) 2. 如果想获取东西,在框中输入:DebugSpa...