zoukankan      html  css  js  c++  java
  • Two scripts work with git pull/push

    作为一个程序员,工作中总是会用到一些tool,而且经常会自己开发一些tool。我的地盘,我做主。对于这些tool的版本控制,我选择的是git (公司用的是perforce)。我的代码库是通过dropbox在家里和公司同步的。开发时总是从dropbox上拿最新的版本,git里管这个叫pull。开发结束,再把代码同步到dropbox上,git里这叫push。

    push和pull这两个command运行的时候,需要你在代码库的根目录下运行(根目录下有个.git文件夹)。

    根据这个特点,我就写了下面两个script:

    pullme.bat(从dropbox-p:\repository-上拿最新代码)

       1: @echo off 
       2:  
       3: :POPCD
       4: if exist .git goto SYNC
       5: cd ..
       6: goto POPCD
       7:  
       8: :SYNC
       9:  
      10: git pull p:/Repository
      11:  
      12: @echo Now you are working with the latest copy
      13:  
      14: pause

    pushme.bat(把代码同步到dropbox上)

       1: @echo off 
       2:  
       3: SETLOCAL ENABLEDELAYEDEXPANSION
       4: SETLOCAL ENABLEEXTENSIONS
       5:  
       6: :POPCD
       7: if exist .git goto SYNC
       8: cd ..
       9: set PWD=%CD%
      10: goto POPCD
      11:  
      12: :SYNC
      13:  
      14: p:
      15:  
      16: cd p:/repository
      17:  
      18: git pull %PWD%
      19:  
      20: @echo Now p:/repository is up-to-date
      21: pause

    哥们,看出这两个脚本的方便之处了吗?

    方便之处在于:当你当前处于<root>/A/B/C/…,你没有必要不停的cd..,直到<root>。这么simple and boring的事情,交给script做吧。

  • 相关阅读:
    【C#】C#8.0常用新特性
    【Docker】Asp.net core在docker容器中的端口问题
    【gRPC】ProtoBuf 语言快速学习指南
    【日常排雷】 .Net core 生产环境appsetting读取失败
    【gRPC】 在.Net core中使用gRPC
    raspbian buster阿里镜像
    管道通信
    关于utf8mb4的使用
    ef core数据迁移的一点小感悟
    windows 端口转发
  • 原文地址:https://www.cnblogs.com/jalenwang/p/pull_push_me_for_git.html
Copyright © 2011-2022 走看看