美文网首页
Git简单命令

Git简单命令

作者: 橘子味草莓 | 来源:发表于2018-05-18 14:51 被阅读20次

    hlpdeMacBook-Air:~ hlp$ git clone xxxxxxxxxxxx(远程仓库地址)Cloning into 'liexing_test’…(克隆)

    remote: Counting objects: 3, done.

    remote: Total 3 (delta 0), reused 0 (delta 0)

    Receiving objects: 100% (3/3), done.

    hlpdeMacBook-Air:~ hlp$ cd liexing_test/

    hlpdeMacBook-Air:liexing_test hlp$ git status

    On branch master

    Your branch is up-to-date with 'origin/master'.

    nothing to commit, working tree clean

    hlpdeMacBook-Air:liexing_test hlp$ git checkout -b test(创建分支)

    Switched to a new branch 'test'

    hlpdeMacBook-Air:liexing_test hlp$ git branch(查看分支)

      master

    * test

    hlpdeMacBook-Air:liexing_test hlp$ vim hello.c 

    hlpdeMacBook-Air:liexing_test hlp$ git status(查看改变文件)

    On branch test

    Changes not staged for commit:

      (use "git add ..." to update what will be committed)

      (use "git checkout -- ..." to discard changes in working directory)

    modified:  hello.c

    no changes added to commit (use "git add" and/or "git commit -a")

    hlpdeMacBook-Air:liexing_test hlp$ git add .(添加修改文件)

    hlpdeMacBook-Air:liexing_test hlp$ git commit -m "v0.0.0.1”(添加版本号)

    [test 0002958] v0.0.0.1

     1 file changed, 1 insertion(+), 1 deletion(-)

    hlpdeMacBook-Air:liexing_test hlp$ git push origin test(推到目前分支的远程)

    Counting objects: 3, done.

    Writing objects: 100% (3/3), 250 bytes | 250.00 KiB/s, done.

    Total 3 (delta 0), reused 0 (delta 0)

    To 120.25.81.140:/home/gita/liexing_test

     * [new branch]      test -> test

    hlpdeMacBook-Air:liexing_test hlp$ git status

    On branch test

    nothing to commit, working tree clean

    hlpdeMacBook-Air:liexing_test hlp$ git beanch -a

    git: 'beanch' is not a git command. See 'git --help'.

    The most similar command is

    branch

    hlpdeMacBook-Air:liexing_test hlp$ git branch -a(查看所有分支)

      master

    * test——————(当前分支)

      remotes/origin/HEAD -> origin/master

      remotes/origin/master

      remotes/origin/test(分支的远程)

    hlpdeMacBook-Air:liexing_test hlp$ git checkout master(切换分支)

    Switched to branch 'master'

    Your branch is up-to-date with 'origin/master'.

    hlpdeMacBook-Air:liexing_test hlp$ git merge test(合并分支)

    Updating 562b615..0002958

    Fast-forward

     hello.c | 2+-

     1 file changed, 1 insertion(+), 1 deletion(-)

    hlpdeMacBook-Air:liexing_test hlp$ git status

    On branch master

    Your branch is ahead of 'origin/master' by 1 commit.

      (use "git push" to publish your local commits)

    nothing to commit, working tree clean

    hlpdeMacBook-Air:liexing_test hlp$ git push origin master(推到主分支的远程)

    Total 0 (delta 0), reused 0 (delta 0)

    To 120.25.81.140:/home/gita/liexing_test

       562b615..0002958  master -> master

    hlpdeMacBook-Air:liexing_test hlp$ git status

    On branch master

    Your branch is up-to-date with 'origin/master'.

    nothing to commit, working tree clean

    hlpdeMacBook-Air:liexing_test hlp$ vim hello.c 

    hlpdeMacBook-Air:liexing_test hlp$ git log(查看历史版本)

    commit 0002958209e189a22d0d315286c7ef0bf30eb68d (HEAD -> master, origin/test, origin/master, origin/HEAD, test)

    Author: Frank

    Date:  Wed Jan 17 18:14:27 2018 +0800

        v0.0.0.1

    commit 562b6154ecc16e760f7aa90b8c4bdbf7dcaf3876

    Author: wayne

    Date:  Wed Jan 17 18:09:47 2018 +0800

        v0.0.0.0

    hlpdeMacBook-Air:liexing_test hlp$ 

    相关文章

      网友评论

          本文标题:Git简单命令

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