type
status
date
slug
summary
tags
category
icon
password
Sub-item
Parent item

Git 常用命令

命令
作用
git config –global user.name 用户名
设置用户签名
git config –global user.email 邮箱
设置用户签名
git init
初始化本地库
git status
查看本地库状态
git add 文件名
添加到暂存区
git commit -m “日志信息” 文件名
提交到本地库(将会记录版本)
git reflog
查看历史纪录
git log
查看详细历史记录
git reset –hard 版本号
版本穿梭

分支的操作

命令
作用
git branch 分支名
创建分支
git branch -v
查看分支
git checkout 分支名
切换分支
git merge 分支名
把指定的分支合并到当前分支上

远程仓库操作

命令
作用
git remote -v
查看当前所有远程地址
git remote add 别名 远程地址
添加远程仓库并为其起别名
git push 别名 分支
推送本地分支上的内容到远程仓库
git clone 远程地址
将远程仓库的内容克隆到本地
git pull 远程库地址别名 远程分支名
将远程仓库对于分支最新内容拉下来后与当前本地分支直接合并

SSH连接远程仓库

添加SSH
检查SSH

Git撤销

命令
作用
git checkout .
撤销本地尚未提交的修改(不推荐)
git restore < file >
还原文件到最新提交的状态
git reset < file >
撤销添加到暂存区的文件
git reset HEAD^/git reset –hard HEAD^
撤销最近的一次本地commit
git update-ref -d HEAD && git rm –cached -r .
撤销第一个本地提交
git rebase -i < base-branch >
撤销本地分支上中间的某个提交
git reset HEAD < file > && git checkout < file >
撤销一个本地git rm的文件
git mv < fl2 > < fl1 >
撤销一个本地git mv
Carly Rae Jepsen - The Loveliest TimeHexo文章插入bilibili视频
Loading...