在 github 上更新我的存储库

update my repository on github

我刚刚转到 github 在我的计算机上本地运行的项目。一切顺利,我可以上传我所有的文件..现在我想知道如果我在本地对我的项目进行一些更改,我该如何更新我的存储库 尝试以下命令:

git add.
git pull origin master

我想我忘记了什么,或者我使用的命令不正确,正确的方法是什么?

在 "normal" 情况下,确保将更改正确添加到远程 github 存储库的工作流程应遵循以下阶段..

(1) git status

将始终告诉您哪些未提交,哪些需要"added"(暂存)以提交到您的本地存储库。事实上 git 会提示您它认为您工作流程的下一步是什么

(2) git add <your_file_path_you_can_use_glob_patternsLike_asteriks>

(3) git commit -m "A Nice Subject line for many file commits <enterFromKeyboardGivesYouAnotherLine>
(a) Continue typing more comments which are detailed if necessary <anotherEnterFromKeyboard>
(b) Some more details and do not forget to put closing quote mark"

如果使用 Windows git-bash.exe 则在 Windows 中工作 它使用 mingW64 模拟器来模拟 linux 环境。它非常擅长。

您需要在本地提交您想要保留的任何更改,然后才能远程 "push" 您对 git 集线器存储库的更改,即仅在您告诉 git 您的位置之后远程 git 回购是 .....

(4) git remote add myGitHubOrBitBucketRepo https://github.com/YourGitAppRepo.git

通常 github 上的远程仓库的默认名称为 "origin"。但是我一直在使用特定的别名分支名称,在您的情况下是 "myGitHubOrBitBucketRepo"

(5) git push -u myGitHubOrBitBucketRepo HEAD:master

此命令会将您提交的更改(在 git 中称为快照)推送到 github.com 上的 YourGitAppRepo.git 到 master 分支上,如果您的远程仓库上的 master 不在前面你当地的分支机构,它只是落后的几个提交 - github.com 将接受这个推送

-u 与 --track 相同,这意味着位于@HEAD 的本地分支将跟踪远程别名 myGitHubOrBitBucketRep 的主分支

在第 4 步和第 5 步中,您必须使用用户 ID 和密码与 GitHub.com

上的远程存储库进行交互
(6) git status

从现在开始,git status 实际上会告诉你你是落后于还是领先于你的远程 github 仓库,因为你在推送中使用了 --track (ing) 选项

从现在开始使用的另一个有用的命令是

git branch -vv --all

一个例子

$ git branch -vv --all
* CurrAsOf18Jan2018             50d1fc6 [remotes/bitbucketFrmWin/master: behind 5] Pedantic but done - gitNotes.txt
  remotes/bitbucketFrmWin/master        58470cd [CurrAsOf18Jan2018] This is really crazy - Spent more than a week - Singleton still gives

这里的 bitbucketFrmWin 是我的远程 bitbucket 存储库的别名 AsOf16Jan2018 是我不再感兴趣的分支 master 是我当前的主要分支,我将我的更改从我的本地存储库推送到它。

--all 选项还将显示您的本地和 "remotes"

注意事项如下 * CurrAsOf18Jan2018 50d1fc6 [remotes/bitbucketFrmWin/master:落后 5]

星号 * 是我本地分支的 HEAD 或我所在分支的提交。通常它总是在尖端或头部,即为什么它被称为 "head"

CurrAsOf18Jan2018 是我的本地主要分支,重要的是它说我的本地分支已经领先我的远程分支 5 个提交 - 它已经过时所以我需要用 "git push"[ 更新我的远程分支=19=]

现在这只是这个故事的一方面。如果您的远程回购继续进行,那么另一个工作流程将是

git fetch --all && git merge --ff-only <theCommitYouWantYouToCatchUpWith>

这完全是另一个 post。

这是一张简洁的图片,由 Oliver Steele 友情提供,显示了版本控制的基本 git 工作流生命周期的另一个版本

希望这对您有所帮助。

git add .
git commit -m "my changes" 
git remote add origin https://github.com/zinmyoswe/React-and-Django-Ecommerce.git
git push -u origin master