美文网首页
git commands

git commands

作者: 一个半吊子工程师 | 来源:发表于2020-11-27 10:14 被阅读0次

暂存区和分支都属于版本库,修改的地方是工作区。

创建目录:
mkdir dir_name
显示当前目录:
pwd
初始化库:
git init
添加远程库:
git remote add origin git@github.com:Redbackkk/xxxxx.git

提交到暂存区:
git add <filename>
提交到分支:
git commit -m "messages"
回到历史版本:
git reset --hard <commit-id>
丢弃工作区的修改(恢复成最近commit的版本):
git restore <filename>
丢弃暂存区的修改:
git restore --staged <filename>
删除文件:
git rm <filename>

查看当前工作区状态:
git status
查看日志(commit-id和message)(树状图):
git log --graph --pretty=oneline --abbrev-commit
查看更新:
git diff <commit id 前五位即可>
查看命令日志:
git reflog
整理log graph:
git rebase

查看分支:
git branch
创建分支:
git branch <branchname>
切换分支:
git swith <branchname>
*创建并切换分支:
git switch -c <branchname>
合并某分支到当前分支:
git merge <branchname> --no-ff (该参数可以看出合并)
删除分支:
git branch -d <branchname> (大写D强制删除)
将部分修改merge到当前分支(修复bug后,修改dev分支):
git cherry-pick <commit-id>

查看挂起工作区列表:
git stash list
保存工作区:
git stash
恢复工作区:
git stash pop / git stash apply stash@{x}

查看标签:
git tag
添加标签:
git tag <tagname> [commit-id -m "description" ]
推送标签:
一个:
git push origin <tagname>
全部:
git push origin --tags
删除本地标签:
git tag -d <tagname>
删除远程标签:
git push <远程库> :refs/tags/<tagname> (远程库默认为origin)

查看远程库:
git remote (-v 显示详细信息)
推送分支:
git push <远程库> <branchname>
抓取分支:
git clone git@aaa.xxx:username/repository.git
创建本地dev分支:
git switch -c dev origin/dev

相关文章

  • git help

    These are common Git commands used in various situations:...

  • Git Commands

    Clone 1. git clone 2.Check the remote repo...

  • git commands

    1. To see the URL of local repository git remote show ori...

  • git: commands

    …or create a new repository on the command line echo "# g...

  • git commands

    暂存区和分支都属于版本库,修改的地方是工作区。 创建目录:mkdir dir_name显示当前目录:pwd初始化库...

  • Git笔记

    Git Commands tips:<*> means required,[*] means optional 基...

  • 记不住git命令?试试这个命令浏览网站

    Find the right git commands without digging through the w...

  • Basic Git commands

    To use Git, developers use specific commands to copy, cre...

  • A Cup of Git Latte

    Quick reference for some frequently used Git commands. Se...

  • git cmd

    GitHub Commands git 常用命令 注册 SSH key 以便git bash 可以push req...

网友评论

      本文标题:git commands

      本文链接:https://www.haomeiwen.com/subject/zcgtwktx.html