美文网首页
Git 基本使用

Git 基本使用

作者: small_zeo | 来源:发表于2018-11-04 10:32 被阅读0次

1.Git 仓库

初始化版本库: git init

2.查看仓库状态

git status

pwd 显示当前命令行所在目录

ls -a 显示隐藏文件 .开头的文件一般都是隐藏目录

echo "git test"  >> test.txt  将 "git test" 追加到 test.txt 文件中

cat test.txt 展示当前文件内容

git add test.txt  将test.txt 添加到工作区

git commit -m "git test" 将test.txt 添加到git 仓库中

3.git add bash.txt 但没有commit  回滚到之前的状态:

git reset HEAD bash.txt

此时工作区的文件没有变更,则:

git checkout --bash.txt 即可

4.git add bash.txt     git commit -m "git test" ,此时要回滚到某个版本:

git log 

git reset --hard 123456****

5.清空本地文件仓库

git rm bash.txt

git commit -m "ssss"  清空仓库

6.添加远程仓库

git remote add origin git@****.git 

git pull origin master

git push -u origin master

7.远程先开好分支然后拉到本地

git checkout -b feature-branch origin/feature-branch //检出远程的feature-branch分支到本地

8.本地先开好分支然后推送到远程

git checkout feature-branch      //切换到分支feature-branch 

git push origin feature-branch:feature-branch //推送本地的feature-branch(冒号前面的)分支到远程origin的feature-branch(冒号后面的)分支(没有会自动创建)

9.创建空白分支

创建一个分支

git checkout --orphan dev

清空文件

git rm -rf .

10.合并分支

切换到master 分支

git merge feature-branch

11.删除本地分支

切换到master 分支

git branch -d feature-branch

12.远程删除git服务器上的分支

git push origin -d feature-branch

13.删除本地的远程分支

git branch -r -D origin/feature-branch

相关文章

  • git 的使用

    有关git的使用总结一下,留着使用 git、svn区别 使用过程 svn基本使用过程 git基本使用过程 管理模式...

  • [Git使用] git基本使用

    GIT常用命令新建Git仓库,创建新文件夹 git init添加文件到git索引 git add

  • git的基本使用

    git的基本使用

  • git 命令语法

    git 基本使用 git init // 初始化git仓库 git add . // git 添加 git co...

  • 初识git,用git 上传项目到GitHub

    分享一些git基本指令,不喜勿喷! git的基本使用指令 git init 初始化git仓库 git add . ...

  • Git 基本使用

    1.CentOS 7 安装Git 安装git所需要的库yum install curl-devel expat-d...

  • Git基本使用

    ps -ef | grep node | awk '{print $2}' | xargs kill -9git ...

  • Git基本使用

    1:先设置git配置文件 1.1 查看配置文件 1.2 设置对应用户名和邮箱 2:生成公钥和私钥 执行命令后需...

  • git 基本使用

    一、git全局设置 git全局配置修改 git config -e --global 进步全局配置文件,然后点击字...

  • Git 基本使用

    1.Git 仓库 初始化版本库: git init 2.查看仓库状态 git status pwd 显示当前命令行...

网友评论

      本文标题:Git 基本使用

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