首页 > 其他分享 >GIT

GIT

时间:2022-11-30 18:32:05浏览次数:36  
标签:200 GIT git wang -- tag root

GIT

1、配置git环境常用命令
root@wang-200 git]# git init

[root@wang-200 git]# git config --global user.name wang
[root@wang-200 git]# git config --global user.email [email protected]

[root@wang-200 git]# git config -l
user.name=wang
[email protected]
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
[root@wang-200 git]# git config color.ui auto

[root@wang-200 git]# git config -l
user.name=wang
[email protected]
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
color.ui=auto

[root@wang-200 git]# git config core.editor vim

[root@wang-200 git]# git config -l
user.name=wang
[email protected]
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.editor=vim
color.ui=auto
2、创建、提交
[root@wang-200 git]# vim README.md
[root@wang-200 git]# git status
[root@wang-200 git]# git add .

[root@wang-200 git]# git commit

[root@wang-200 git]# git status

[root@wang-200 git]# git log --stat

1 file changed, 1 insertion(+)
[root@wang-200 git]# git log

[root@wang-200 git]# git log -p

[root@wang-200 git]# git log --oneline
3、撤销提交(慎用或不用)
git add deploy.yaml
git commit -m "version 2"
git log --oneline

git reset --soft 19d31ba
git reset --mixed 19d31ba
git reset --hard 94b969e

#说明:
--soft:仅移动HEAD和master指针的指向,不会重置暂存区或工作区
--mixed:仅重置暂存区,自commit之后暂存到暂存区的修改将移回工作区
--hard:同时重置暂存区和工作区,这意味着自commit之后所做出的的有修改都将会丢失
4、远程仓库
[root@wang-200 git]# git remote add origin https://gitee.com/dayu-w/git.git
[root@wang-200 git]# git push -u origin "master"
Username for 'https://gitee.com': 135*****070
Password for 'https://135*****[email protected]':
Counting objects: 10, done.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (10/10), 894 bytes | 0 bytes/s, done.
Total 10 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/dayu-w/git.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.



[root@wang-200 git]# git remote -v
origin https://gitee.com/dayu-w/git.git (fetch)
origin https://gitee.com/dayu-w/git.git (push)


[root@wang-200 git]# git clone https://gitee.com/dayu-w/git.git



[root@wang-200 git]# git fetch


# 说明
抓取远程仓库上的变动
◼ 命令:git fetch
◼ 它只会抓取远程仓库中的变动至本地版本库中,但不会修改工作区

拉取远程仓库上的变动
◼ 命令:git pull
◼ 它会拉取远程仓库中的变动至本地版本库中,而且会通过合并(merge)操作修改本地工作区

其它操作
◼ 重命名远程仓库:git remote rename <oldName> <newname>
◼ 删除本地仓库上配置的远程仓库:git remote remove <remoteRepoName>
5、Tag
[root@wang-200 git]# git tag hah
[root@wang-200 git]# git tag -l
hah
[root@wang-200 git]# git tag -a addon-tag -m test-addon-tag
[root@wang-200 git]# git tag -l
addon-tag
hah
[root@wang-200 git]# git log --oneline
94b969e v6
19d31ba v2
4b8a397 test
[root@wang-200 git]# git tag -a tag-namewang -m tag-message-test 19d31ba
[root@wang-200 git]# git tag -l
addon-tag
hah
tag-namewang
[root@wang-200 git]# git tag -d hah
Deleted tag 'hah' (was 94b969e)
[root@wang-200 git]# git tag -l
addon-tag
tag-namewang
[root@wang-200 git]# git push --tags

[root@wang-200 git]# git push --delete origin addon-tag tag-namewang
Username for 'https://gitee.com': 135*****070
Password for 'https://135*****[email protected]':
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/dayu-w/git.git
- [deleted] addon-tag
- [deleted] tag-namewang



#说明

创建标签
◆轻量标签:git tag <tagName>
◆附注标签:git tag -a <tagName> -m <message>
◆给指定的commit打标签:git tag -a <tagName> -m <message> <commitID>

删除标签
◆git tag -d <tagName>

显示标签
◆列出:git tag -l
◆显示标签的详细信息:git show <tagName>

检出标签
◆git checkout <tagName>
◆注意:检出到标签,会导致分离头指针,且新创建的提交也将处于分离的状态

推送标签至远程仓库
◆推送特定标签:git push origin <tagName>
◆推送所有标签:git push --tags

删除远程仓库上的标签
◆git push --delete origin <tagName>
6、branch分支管理
[root@wang-200 git]# git branch devel
[root@wang-200 git]# git branch -l
devel
* master
[root@wang-200 git]# git checkout devel
Switched to branch 'devel'
[root@wang-200 git]# git branch -l
* devel
master


[root@wang-200 git]# git branch -l
devel
* master
[root@wang-200 git]# git merge devel
Already up-to-date.



# 说明
创建分支
命令:git branch <branchName>
◆git branch devel

切换分支
◼ 命令:git checkout <branchName>
◆git checkout devel

分支合并
◼ 命令:git merge <branchName>
◆将指定的其它分支合并至当前分支
◼ 分支合并存在两种情形
◆快进式合并(Fast-Forward Merge)
◆三路合并(3-Way Merge)
7、变基
关于rebase
◼ 命令:git rebase <baseName>
◼ rebase操作也能完成分支合并
◼ 相对于merge操作将一个分支上的所有变动一次性完成合并来说,rebase操作可以保留一个线性的变更历史
8、远程仓库命令总结
设定远程仓库
◼ 添加: git remote add <remote-name> <remote-url>
◼ 列出: git remote -v
◼ 删除: git remote rm <remote-name>
◼ 重命名: git remote rename <old-remote-name> <new-remote-name>

克隆远程仓库
◼ 克隆: git clone <remote-url>
◼ 克隆到指定工作目录: git clone <remote-url> <working-directory-name>

远程协作
◼ 抓取远程仓库所有分支上的变更: git fetch <remote-name>
◼ 抓取远程仓库指定分支上的变更: git fetch <remote-name> <branch-name>
◼ 列出所有远程分支:git branch -r
◼ 将远程分支合并至本地分支,通常应该将存在映射关系(通常为同一个分支名称)的分支进行合并
◆git checkout <branchName>
◆git merge origin/<branchName>

拉取远程仓库上的变更
◼ 拉取并合并当前分支映射的远程分支上的变更至本地工作区:git pull <remote-name>
◼ 相当于如下两个命令生成的结果
◆git fetch <remote-name> <current-branch-name>
◆git merge <remote-name> <current-branch-name>

推送本地变更到远程仓库
◼ 推送指定的分支:git push <remote-name> <branch-name>
◼ 推送本地仓库中的所有分支:git push <remote-name> --all
◼ 推送本地仓库中的所有标签:git push <remote-name> --tag

标签:200,GIT,git,wang,--,tag,root
From: https://blog.51cto.com/dayu/5900129

相关文章

  • Git相关操作总结
    1.查看仓库信息gitremote-v2.初始化git仓库gitinit3.添加远程仓库地址gitremoteaddorigin仓库地址4.从远程仓库克隆下载代码gitclone-b分支名称远程......
  • 三. 基于Jenkins与Gitlab的CI/CD及DevOps实战 -2
    基于Jenkins与Gitlab的CI/CD及DevOps实战DevOps介绍:OPS部分职责:1.通过监控、告警、人工值守等方式保证应用程序的7*24的可用性。   2.系统选型、基础环境初始......
  • 查看git分支是从哪个源分支建立出来的
    打开git客户端,执行如下命令gitreflog--date=local|grep分支名称可以看出test分支是基于master建立出来的......
  • VS中Git的简单使用与说明
    一:基本操作VisualStudio通过下载(提取和拉取)和上传(推送)操作来使本地分支与远程分支保持同步。1:提取:就是从远端仓库获取最新的代码,但是不应用,类似于“检查更新”2:拉取:及......
  • Git常用命令
    gitinit 在目录中创建新的Git仓库gitclone   使用gitclone拷贝一个Git仓库到本地    gitclone[url]   [url]为你想要复制的项目,就可以了。git......
  • Git stash被误删恢复策略
    场景:通过stash保存,被使用gitstashdrop丢起。项目开发中,不想commit提交,但要切换到其他commit或者branch,临时处理紧急任务,使用gitstash备份当前的工作内容。但因不......
  • Visual Studio 第一次上传代码至gitee
    前情概要今天尝试将自己在Visualstdio上写的代码上传至gitee上,解决历程通过Git    将码云上这个地址复制至2中   会让你输入以下用户名, 密码不......
  • Visual Studio 2022 提交git代码
    VisualStudio2022更换了全新的git提交方式,接下来实践一下。我们以gitte作为远程仓库参考实践一下环境说明环境和版本很重要,大量的博客没有环境说明和版本介绍,对新......
  • IntelliJ IDEA:Unregistered VCS root detected. The directory…is under Git, but i
    https://blog.csdn.net/CHENYUFENG1991/article/details/74136439/当我们在IDEA中导入一个Git项目或者初始化一个Git项目的时候,往往会出现“UnregisteredVCSrootdetect......
  • coding上创建项目、创建代码仓库、将IDEA中的代码提交到coding上的代码仓库、Git的下
    一、Git的安装以及子啊IDEA上配置Git(下载好的可以跳过)git官网:https://git-scm.com/参考这位博主的git下载教程。也是很详细()https://blog.csdn.net/orange228/article/det......