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

2.1k views Asked by At

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?

3

There are 3 answers

0
iandin On

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

0
interceptor011 On

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

0
nbalas On

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.