AWS EB CLI + Codecommit: git status incorrectly shows branch out-of-sync after deploy

喜夏-厌秋 提交于 2019-12-11 08:25:07

问题


After using "eb deploy" integrated to source control the CodeCommit remote repo is updated (I can see in AWS Console that the commit is there, in the cloud repo) and the EC2 instance is correctly running the new deployed version (can see it also through AWS Console).

The problem: all things are synced but GIT says the remote repo is one commit behind it is actually is.

When I type "git status" it says: Your branch is ahead of 'codecommit-origin/master' by 1 commit. (use "git push" to publish your local commits)

When I type "git log codecommit-origin/master" is does not show the last commit.

Why is GIT saying my local repo is ahead of remote when clearly in the AWS Console the remote CodeCommit repo is up-to-date? Could be that "eb deploy" pushing to CodeCommit is not actually a "git push" command?


回答1:


I actually have "re-run" the command eb init -i going through the setup again and it worked:

...

Note:
Elastic Beanstalk now supports AWS CodeCommit; a fully-managed source control service. 
Do you wish to continue with CodeCommit? (y/n) (default is n): y

Select a repository
1) ppm
2) Create new Repository
(default is 2): 1

Select a branch
1) master
2) Create new Branch with local HEAD 
(default is 1): 1

Do you want to set up SSH for your instances?
(y/n): n

Then I run git status and git log codecommit-origin/master and things are correctly synced now:

$ git status
On branch master
Your branch is up-to-date with 'codecommit-origin/master'.
nothing to commit, working directory clean




回答2:


The EB CLI is doing an git push under the hood but it builds its own credentials to do that push instead of using the aws git credential helper.

Although the CLI will still setup the HTTPS credentials specified in the documentation in the AWS Documentation.

The fact that your local git repository is out of sync is because the EB CLI runs it's git actions using a separate method than you would running them in your command line. You can use the command git fetch to sync your local branch with the remote to get the most up-to-date status from git status.

If you are using OSX there is a known issue with the Keychain Access utility and the workaround is specified in section 3.3 of the link I provided.




回答3:


When you are doing eb init, and when you come to this part:

Note: Elastic Beanstalk now supports AWS CodeCommit; a fully-managed source control service. To learn more, see Docs: https://aws.amazon.com/codecommit/ Do you wish to continue with CodeCommit?

you should answer no (N). That way, eb won't make another origin (codecommit-origin).

I do it whis way:
1. git clone from CodeCommit repo.
2. eb init without CodeCommit.
3. create branch (eg. development, git branch development).
4. eb use development-env
5. eb deploy



来源:https://stackoverflow.com/questions/41433772/aws-eb-cli-codecommit-git-status-incorrectly-shows-branch-out-of-sync-after-d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!