0
votes

i have one local git repository, and i created one cron job to push from local git repository to Codecommit in every 10 mins, all developers are pushing there code to local git repository. but i have two aws account, i want same cron job will push code to second aws codecommit account also.

one config file we need to create in .ssh directory which we can create using aws-iam, but can i add to iam-access key for codecommit in one config file? if you have any batter solution please suggest me.

1
Why do you want your source code in two locations like this? Andy why are you using a cron? You typically push code up to a origin master when you have valid changes to push.George M Whitaker
actually in one account we are running production, but for security we are moving staging to different account in staging account we are using codedeploy with jenkins.. with some other branch.. and in local git changes from developers are coming in every 4-5 mins, that's way i'm using cron job for pushing to codecommit @GeorgeMWhitakerSiddharth Sharma
OK that makes sense. I think I would still do one repo (codecommit) . I am assuming you are using codecommit to trigger builds/deploys. In doing so you can then create triggers based on the branch. So your production branch triggers a deploy/build for production systems. If if they are in a different account. In my opinion having developer configure their machine to ensure your process works is a recipe for trouble. Developer setup should be dirt simple and your centralized tools should be configured to do the rest.George M Whitaker

1 Answers

2
votes

In recent git versions, it is possible to push simultaneously to more than one remotes.

To do this, I would recommend adding a new remote called all which, when you are using it, makes it clear that you are pushing to multiple remotes.

git remote add all git://HostA/repo1.git

Now add distinct pushurls for as many remotes as you wish like so:

git remote set-url --add --push all git://HostA/repo1.git
git remote set-url --add --push all git://HostB/repo2.git
git remote set-url --add --push all git://HostC/repo3.git

Finally, to push to all of them, use:

git push all master

(where master is the local branch you want to push from)