首页 > 其他分享 >Git常用命令

Git常用命令

时间:2023-01-17 00:00:31浏览次数:37  
标签:git name 仓库 Git branch 常用命令 push 远程

Git常用命令

基础操作

  • git status:查看文件状态

  • git add:将文件的修改加入暂存区

  • git reset:将暂存区的文件取消暂存或者是切换到指定版本

  • git commit:将暂存区的文件修改提交到版本库

  • git log:查看日志

远程仓库操作

  • git remote:查看远程仓库

  • git remote add:添加远程仓库

  • git clone:从远程仓库克隆

  • git pull:从远程仓库拉取

  • git push:推送到远程仓库

将本地仓库内容推送到远程仓库:

git push 【remote-name】【branch-name】

注意:如果当前本地仓库不是从远程仓库克隆,而是本地创建的仓库,并且仓库中存在文件,此时再从远程仓库拉取文件的时候会报错(fatal:refusing to merge unrelated histories)

解决此问题可以在pull命令后加入参数:--allow-unrelated-histories

分支操作

  • git branch 查看分支

  • git branch 【name】 创建分支

  • git checkout 【name】 切换分支

  • git push 【shortName】【name】推送至远程仓库分支

  • git merge【name】 合并分支

标签操作

  • git tag:列出已有的标签

  • git tag【name】:创建标签

  • git push 【shortName】【name】:将标签推送至远程仓库

  • git checkout -b【branch】【name】,检出标签

标签:git,name,仓库,Git,branch,常用命令,push,远程
From: https://www.cnblogs.com/mhy123/p/17056748.html

相关文章

  • 安装完Git鼠标右键不显示或者打不开Git Bash Here和Git GUI Here的问题
    问题:安装完Git后,右键(WIN11中右键后还需要点击->显示更多选项)发现缺少/打不开GitBashHere和GitGUIHere,或是其中之一。解决:①win+r打开运行,输入:regedit②按图片......
  • git使用(复健 1 )
    #```shell#ubuntu:sudoapt-getinstallgit```###winodwshttps://git-scm.com/downloads设置用户名和邮箱:```bash$gitconfig--globaluser.name"YourName"$g......
  • Git统计代码修改行数
    通过Git的命令可以统计自己在一段时间内的代码更改数量,具体代码如下:根据用户名来统计gitlog--author="username"--pretty=tformat:--numstat|\awk'{add+=$1;su......
  • Docker(常用命令)
    帮助启动类命令启动docker:systemctlstartdocker停止docker:systemctlstopdocker重启docker:systemctlrestartdocker查看docker状态:systemctlstatusdocker开机启动......
  • 关于GIT使用的扫盲知识
      关于GITa)     什么是git用于团队里各成员协同开发项目的一个代码管理工具。与之SVN、微软的TFS是同一类东西。而git是时下最火的代码管理工具。b)   ......
  • Linux常用命令
    Linux中许多常用命令是必须掌握的,这里将我学linux入门时学的一些常用的基本命令分享给大家一下,希望可以帮助你们。date#显示或设定系统的日期与时间。ls#列......
  • Fix for PowerShell Script Not Digitally Signed
    Whenyouruna.ps1PowerShellscriptyoumightgetthemessagesaying“.ps1isnotdigitallysigned.Thescriptwillnotexecuteonthesystem.”Tofixity......
  • GIT常见命令(一)
    参考:https://blog.csdn.net/liuxiaoheng1992/article/details/79108233https://www.cnblogs.com/rainboy2010/p/12671633.htmlhttps://www.cnblogs.com/marblemm/p/7161......
  • dockercompose搭建GITLAB上传代码
    1.创建挂载目录:mkdir-p/home/yuexin/gitlab/etc/home/yuexin/gitlab/log/home/yuexin/gitlab/data2.编写dockercomposeversion:'3.7'services:gitlab:im......
  • github无法访问解决方法
    1.分别打开https://tool.chinaz.com/dns/?type=1&host=github.com&ip=和https://tool.chinaz.com/dns/?type=1&host=github.global.ssl.fastly.net&ip    2.ma......