• <nav id="wkkge"><strong id="wkkge"></strong></nav>
  • <menu id="wkkge"></menu>
  • Git教程
    Git標簽管理
    Git分支
    Git操作
    Git應用
    GitHub應用
    IDEA對于Git&GitHub的支持
    Git與GitHub使用注意事項

    Git移動操作

     

     

    顧名思義,移動操作將目錄或文件從一個位置移動到另一個位置。例如,我們想要將源代碼移動到src目錄中。修改后的目錄結構將顯示如下:

     

    Administrator@MY-PC /D/worksp/sample (master)
    $ pwd
    /D/worksp/sample
    
    Administrator@MY-PC /D/worksp/sample (master)
    $ ls
    README.md  main.py
    
    Administrator@MY-PC /D/worksp/sample (master)
    $ mkdir src
    
    Administrator@MY-PC /D/worksp/sample (master)
    $ git mv main.py src/
    
    Administrator@MY-PC /D/worksp/sample (master)
    $ git status
    On branch master
    Your branch is up-to-date with 'origin/master'.
    
    Changes to be committed:
      (use "git reset HEAD ..." to unstage)
    
            renamed:    main.py -> src/main.py
    
    Changes not staged for commit:
      (use "git add ..." to update what will be committed)
      (use "git checkout -- ..." to discard changes in working directory)
    
            modified:   src/main.py
    
    

     

    為了使這些更改永久性,必須將修改的目錄結構推送到遠程存儲庫,以便其他開發人員可以看到這些更改。

     

    $ git add .
    
    Administrator@MY-PC /D/worksp/sample (master)
    $ git commit -m "Modified directory structure"
    [master 186df84] Modified directory structure
     1 file changed, 3 insertions(+)
     rename main.py => src/main.py (78%)
    
    Administrator@MY-PC /D/worksp/sample (master)
    $ git push origin master
    Username for 'http://git.oschina.net': 769728683@qq.com
    Password for 'http://769728683@qq.com@git.oschina.net':
    Counting objects: 5, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (3/3), done.
    Writing objects: 100% (4/4), 491 bytes | 0 bytes/s, done.
    Total 4 (delta 0), reused 0 (delta 0)
    To http://git.oschina.net/bjpowernode/sample.git
       ef07ab5..186df84  master -> master
    
    

     

    在其它開發人員的本地存儲庫中,在執行git pull操作之前,它將顯示舊的目錄結構。在另外一臺開發者機器上,執行以下命令:

     

    bjpowernode@ubuntu:~/git/sample$ pwd
    /home/bjpowernode/git/sample
    bjpowernode@ubuntu:~/git/sample$ ls
    main.py  master  README.md
    bjpowernode@ubuntu:~/git/sample$
    
    

     

    但是在執行git pull操作之后,目錄結構將被更新。 現在,假設在另外一個開發人員(minsu)執行git pull操作之后,就可以看到目錄中的src目錄和文件了。

     

    bjpowernode@ubuntu:~/git/sample$ git pull
    remote: Counting objects: 10, done.
    remote: Compressing objects: 100% (9/9), done.
    remote: Total 10 (delta 2), reused 0 (delta 0)
    Unpacking objects: 100% (10/10), done.
    From http://git.oschina.net/bjpowernode/sample
       01c5462..186df84  master     -> origin/master
    Updating 01c5462..186df84
    Fast-forward
     main.py => src/main.py | 11 +++++++++++
     1 file changed, 11 insertions(+)
     rename main.py => src/main.py (58%)
    bjpowernode@ubuntu:~/git/sample$ ls
    master  README.md  src
    bjpowernode@ubuntu:~/git/sample$ ls src/
    main.py
    bjpowernode@ubuntu:~/git/sample$
    

     

    全部教程
  • <nav id="wkkge"><strong id="wkkge"></strong></nav>
  • <menu id="wkkge"></menu>
  • 面对面棋牌游戏