zoukankan      html  css  js  c++  java
  • git 在本地备份与指定不需要管理文件

    git 在本地备份

    备份文件夹操作

    在本地备份文件夹克隆一个不带工作区的仓库:

    哑协议:
    
    git clone --bare <workspace>/.git yourwork.git
    
    git clone --bare file:///<workspace>/.git yourwork.git
    
    

    工作文件操作

    若是没有关联远端仓库,在本地工作文件直接git push会提示添加远端仓库。

    $ git push 
    fatal: No configured push destination.
    Either specify the URL from the command-line or configure a remote repository using
    
        git remote add <name> <url>
    
    and then push using the remote name
    
        git push <name>
    
    

    看到以上信息,按照提示进行添加。

    在项目仓库中,将本地仓库与远端备份仓库进行连接:

    添加远端仓库:
    
    git clone --bare <workspace>/.git yourwork.git
    
    git remote add <name>  file:///<workspace>/yourwork.git
    
    

    可使用git remote -v 查看添加的远端仓库。

    $ git remote -v 
    <yourwork>   file:///<workspace>/<yourwork>.git (fetch)
    <yourwork>   file:///<workspace>/<yourwork>.git (push)
    

    git remote 后,将通过git push <yourwork> master 本地上传到远端。

    同时可以通过--set-upstream设置一个默认的远端分支。

    $ git push adhoc
    fatal: The current branch master has no upstream branch.
    To push the current branch and set the remote as upstream, use
    
       git push --set-upstream adhoc master
    

    指定不需要管理的文件

    在工作目录下建立.gitignore文件:

    <yourwork>/#vim .gitignore
    <yourwork>/#cat.gitignore
    *.o
    #文件夹下文件管理
    /*.o    
    main
    
  • 相关阅读:
    Spring Cloud Eureka的学习
    Maven环境配置
    Maven解决静态资源过滤问题
    Linux Desktop Entry文件配置解析
    iptables规则持久化
    Markdown学习总结
    输vim /etc/rc.d/init.d/mysqld 报错 …..localdomain.pid
    UE4 集成讯飞听写插件
    单机梦幻西游
    使用A*寻路小记
  • 原文地址:https://www.cnblogs.com/zhuandshao/p/12072103.html
Copyright © 2011-2022 走看看