Git 应用

1. initialize new repository

   1)   mkdir e:/prj/repo   //make directory where u want your repository in

   2)  cd e:/prj/repo

   3)  git init

   4)   //copy your codes directory to the directory your made just before 

   5)   add “.gitignore" file  //Ignoresomefiles, folders, need not submit

        //************************************************************************//

        //**************example for one .gitignore file *************************//

*.idb
*.obj
*.sbr
*.bsc
*.ilk
*.pdb
*.ncb
*.plg
*.pch
*.bak
.svn
.svn-base  

    //*********************************.gitignore file end*****************************************//

    6) //add your code directroy to local repository

        git add MyDir

   7) commit change to local repository

       git commit -m "

   8) review the log

        git log

    //Information like the following will be shown

 

//******************************Informaion start *****************************************//

$ git log
commit 0a42a7179f1fe830f9d226856698b1dc97c150ff
Author: user <
wangyilong163@163.com>
Date:   Thu Jul 26 18:24:19 2012 +0800

    Initlize repository for control OrderMake source

user@ASUS-E504D7A0F1 /e/prj/repo (master)
$

 //******************************Information end**************************************//

 9) Now the initialize procedure is complete.You can control your code in local.

     If u want your codes can administ by other PC ,please refer to <<add local repository to server>>.

2. Update your changes to local repository

      git commit -a -m "Change ... for ..."

3. Update your change to server repository

     1)  git commit -a -m "Changed ... for ..."

     2)  git push --repo url

           Example : git push --repo /home/repo/order.git

                            git push --repouser@192.13.1.146:/home/repo/order.git

4. get one repository from the Git server

     git clone [url]

     Example :  git clone /home/repo/order.git

                         git clone user@192.12.1.146:/home/user/order.git

 

      Descriptor:

  • <user>   which is user name in server (192.12.1.146)
  • /home/user/order.git  is absolute path in server side。If use relative path ,write like this "git clone user@192.12.1.146:order.git

 

5. add file(s)

      git add "file" //Note: After this command ,only "add" command is recorded to repository,the file is not added to repository yet.  

6. delete file(s)

7.  create branch

       git checkout -b vga-version master //create "vga-version" branch form "master" branch

8.  merge branch

       1)  git checkout master

        2) git merge "branch"  //"branch" is the branch which will be merged to "master " branch 

9. tag

10. get the history version or history file

        1) git log  //show all versions to find out which version is you need

        2) git checkout "ID of commition"

       3) git checkout "file"  //get file commited at last time

11. abandon your change from lastest commition

          git  reset --hard

 

12. Compare difference version in repository

          1)  git diff   //compare difference between current edit and latest version commited to repository

          2)  git diff ffd98b291e0caa6c33575c1ef465eae661ce40c9 b8e7b00c02b95b320f14b625663fdecf2d63e74c

               //compare two versions have been saved in repository

 

13. add local repository to server

    a) in the PC your local repository saved in,

          1)  git clone --bare . "DestDir"   

               //"DestDir" means the direcroy u want your repository save to.

          2)  ssh-keygen -t rsa  //generate your key and save it to file

          3)  //transmit your "KeyCode.pub" and "DestDir" to administrator

   b) in server side

        1) copy your bare repository to "/home/repo/

             copy your keycode.pub to keydir of gitosis-admin repository

        2) change owner of this repository

              chown -R "Admin" "RepoDir"

        3) modify  ".gitosis.conf" file

           Example :

          [group OrderMake]

          members = user@Coall-workStation1 root

         writable = OrderMake

 

     

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值