git 怎么备份本地分支_git 在本地备份与指定不需要管理文件

git 在本地备份

备份文件夹操作

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

哑协议:

git clone --bare /.git yourwork.git

git clone --bare file:.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

and then push using the remote name

git push

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

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

添加远端仓库:

git clone --bare /.git yourwork.git

git remote add file:yourwork.git

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

$ git remote -v

file:.git (fetch)

file:.git (push)

git remote后,将通过git push 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文件:

/#vim .gitignore

/#cat.gitignore

*.o

#文件夹下文件管理

/*.o

main

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值