我如何使用git备份我的项目? [英] How do I backup my project with git?

查看:416
本文介绍了我如何使用git备份我的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想备份我的项目,所以我试着用

  git init 

然后用

提交所有文件

  git add。 
git commit -am第一次提交

现在我想将它推送到资源库(不仅在本地存储)。



我知道我必须做一些类似于

  git push origin master 

我知道 master 是我的分支的名称,但是 origin



文件存储?我是否必须在GitHub上创建一个存储库,以便这些文件可以存储在GitHub的服务器上,或者有一些Git服务器可以免费存储我的文件(我假设不是:D)?

因此,我必须首先在GitHub上创建存储库,然后使用

  git remote< url_to_GitHub_rep> 


解决方案

在github中创建一个仓库并复制git url类似于 https://github.com/username/gitname.git )。



然后

  git init 

git add。

git commit -m第一次提交

git remote add origin https://github.com/username/gitname.git

git remote -v

git push origin master

然后你会问你的Github用户名&密码。



现在输入Github用户名和密码。



文件将上传到您的存储库。

>

谢谢。


I want to backup my project, so I have tried initializing a rep with

git init

and then commit all files with

git add .
git commit -am "first commit"

and now I want to push it to a repository (which is not only locally stored).

I know I have to do something like

git push origin master

I know that master is the name of my branch, but what is origin?

Where are the files stored? Do I have to create a repository on GitHub, so the files can be stored on GitHub's servers or are there some Git servers which can store my files for free (I assume not :D)?

So do I have to first create the repository on GitHub and then connect my local project with the GitHub repository with

git remote <url_to_GitHub_rep>

解决方案

Create a repository in github and copy the git url(Something Like https://github.com/username/gitname.git ).

Then

git init

git add .

git commit -m "First commit"

git remote add origin https://github.com/username/gitname.git

git remote -v

git push origin master

Then You Will Be Asked Your Github Username & Password.

Now Enter Github Username and Password.

The Files Will Uploaded to your repository.

Thank You.

这篇关于我如何使用git备份我的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆