Git是一种分布式版本控制系统,用于跟踪代码的更改并协作开发。下面是一些常用的Git基本命令:
设置用户签名
git config --global user.name lushanyanyv
git config --global user.email 1924884531@qq.com
获取软件配置信息
git config -l
初始化一个新的Git仓库:
git init
查看当前文件状态:
git status
添加文件到暂存区:
git add <file>
删除暂存区文件
git rm --cached <file>
提交更改到本地仓库:
git commit -m "版本" <file>
日志
git reflog
git log
回滚
git reset --hard <版本>
克隆(拷贝)一个远程仓库到本地:
git clone <repository-url>
查看文件的具体更改:
git diff <file>
创建一个新的分支:
git branch <branch-name>
删除分支:
git branch -d <branch-name>
查看分支
git branch -v
切换到一个分支:
git checkout <branch-name>
合并指定分支到当前分支:
git merge <branch-name>
推送本地更改到远程仓库:
git push <remote> <branch>
拉取远程仓库的最新更改到本地:
git pull
查看远程地址
git remote -v
创建远程库别名
git remote <别名> <地址>
修改远程库别名
git remote rename <old-name> <new-name>
删除远程库
git remote rm <remote-name>