2012-03-17 29 views
0

我是GitHub的新手,它的用法让我有点困惑。我做了一个承诺。现在我想将项目更改为新的重构版本。如何在GitHub上提交新的项目版本?

  1. 是否需要在提交新版本之前从现有回购库中删除文件(如果结构已更改且某些文件不再需要)?
  2. 我是否需要推送或提交?还是我需要做点别的?

回答

1

使commit更新本地计算机上的回购。执行push将在远程复制您的repo更改。

您可以在本地提交多次。一旦你高兴与您的回购的状态,你可以用下面的命令来更新在Github上回购:

git push origin master 

如果你想删除回购文件,你可以这样做:

# remove the file 
git rm path/to/my_file 

# commit the remove to your local repo 
git commit -m "removing my_file" 

# update the remote (Github) repo with the removed file 
git push origin master 

如果回购在Github上还不存在,请继续并在那里创建回购。他们会为您提供关于如何进行第一次提交的分步说明。它可能会是这个样子:

# go to project files 
cd path/to/project 

# initialize git repo 
git init 

# stage all project files in current directory to be committed 
git add . 

# make first commit 
git commit -m "first commit" 

# add the Github remote 
git remote add origin <YOUR GITHUB URL> 

# send repo to git 
git push origin master 
+0

感谢这样一个完整的答案。因此,如果我的计算机上有新版本,我所需要做的就是在新版本的文件夹中使用'git init','git add .','git commit -m'renew structure'','git remote add origin <现有的REPO URL>''和'git push origin master',这会将现有上传项目的所有文件替换为新项目(并且不需要手动删除旧项目中的某些内容),对吧? – 2012-03-17 20:07:34

+0

如果你有一个完全新的结构,你没有建立在现有的回购协议中,我会建议简单地删除旧的回购协议,重新创建它,并上传文件作为新的初始提交。也就是说,如果你项目中的文件不是git仓库的一部分,你只需要'git init'。您可以检查是否存在'path/to/project/.git'来查看您的项目是否有git repo。 – 2012-03-17 23:44:49

+0

我明白了,非常感谢。 – 2012-03-18 21:04:14

1

提交至github上有两个步骤: - >第一次使用命令提交保存更改localy - >然后使用推COMMANDE保存在GitHub上

变化