When there are fatal git clone errors, fetch-pack invalid index-pack output is produced - amazon-web-services

I created a new ec2 instance, however
when I try to clone a git url in html folder
following error is shown:
pack-reused 3 ,
fatal: **fetch-pack**: invalid index-pack output
**clone git url not created project folder **
I tried following alternatives:
git config --global core.compression 0
git clone --depth 1 < git url >
shown project folder
git fetch --unshallow
output: not fetched remote origin
git pull origin branch
failed error : fetch-pack invalid index-pack
git config pack.packSizeLimit 20m
same output error fetch-pack invalid index-pack

It depends on your ec2 T3 instance.
As noted by Dan Langille
This instance type, t3.small, cannot clone the git repo.
Receiving objects: 100% (4907825/4907825), 1.13 GiB | 13.65 MiB/s, done.
fatal: fetch-pack: invalid index-pack output
I seem to recall this problem from earlier attempts with other repos.
I'll try t3.medium with 4GB RAM.
Success.
It seems the minimum level for git clone is t3.medium.

Related

How to deploy 2 CodeCommit repositories using CodeDeploy and CodePipeline with the same appspec.yml?

I have 3 CodeCommit repositories:
Repo 1: App A files
Repo 2: App B files
Repo 3: Some config files for apps A and B + appspec.yml
I would like to create 2 CodePipelines deploying my apps on an EC2. The first one taking Repo1 and Repo3 and then the second one taking Repo2 and Repo3. I want to use the same appspec.yml (because Repo 1 and 2 have the same tree structure and I don't want to duplicate appspec.yml and common config files from Repo3)
It seems like it's not possible to have 2 sources in CodePipeline if the next stage is CodeDeploy. So I decided to put Repo 3 as source and use a BeforeInstall script to git clone Repo 1 or Repo2 depending on the deployment group.
So my appspec.yml looks like that:
version: 0.0
os: linux
files:
- source: config
destination: /var/lib/app
hooks:
BeforeInstall:
- location: scripts/clone-repository.sh
And then clone-repository.sh looks like so
yum install -y git
if [ "$DEPLOYMENT_GROUP_NAME" == "group1" ]
then
git clone <Repo 1>
mv to the right place
etc
elif [ "$DEPLOYMENT_GROUP_NAME" == "group2" ]
then
git clone <Repo 2>
mv to the right place
etc
I was forced to install git otherwise I got an error. I also tried to add these lines
git config --global credential.helper '!aws codecommit credential-helper $#'
git config --global credential.UseHttpPath true
The CodeDeploy role has AWSCodeCommitPowerUser and AWSCodeDeployRole but impossible to git clone. I get the following error -> error: [stderr]: unable to access '': the requested URL returned error: 403
What's missing?
If you have another idea to solve my issue, I'll take it!
Thank you for you help!

How do I deploy an Angular 13 application to Git Hub Pages and not get Readme or 404

tldr; I think I need to add a github token. I have a token from github, but I have no idea how to implement it at the stage that I'm at.
I am trying to deploy an angular 13 app to github pages. Right now, it is just the auto-generated app (I haven't added or changed any code at this point). Here are the steps I have taken
Step 1: Create App and make sure it works
ng new <appName>
cd <appName>
ng serve
Step 2: Create a Repo on Github
Step 3: Check if it automatically connected to a repo (and remove if it's not the one we want)
git remote
git remote -v
git remote remove origin
Step 4: Connect to correct Git Repo (replace variables with username and project name)
git remote add origin <https://github.com/USERNAME/PROJECT_NAME.git>
Step 5: Push to Git repo
git branch -m main
git add .
git commit -m "initial commit"
git push -u origin main
Step 6: Hosting
npm install -g gh-pages
ng build --prod --base-href /PROJECT_NAME/ (find project name in angular.json at very bottom
gh-pages -d dist
When I do all of this, it shows that it worked. But then, it just loads a 404 error. After a lot of googling, I think it has something to do with a token. So I went and got the token, but I'm not sure what to do with it.
P.S. already saw Git Hub Pages not Deploying. (404) and it was unhelpful.
The answer was User Error. The code above works and will deploy an app successfully to gitHub pages.
The problem was I was going to https://humanhickory.github.io/ but the ng build --prod --base-href had actually created a new folder which I had to navigate to (so https://humanhickory.github.io//)
Futhermore, I was able to use the token by running gh-pages -d dist a second time. The first time I did it it said "remote: Invalid username or password. Fatal: authentication failed for '....'". However, when I ran the same command a second time, it prompted me to log in. So there's that.

AWS OpsWorks setup_failed for Instance - unable to deploy_branch

I've had a remote dashboard running fine for a couple of years (written for me by an external developer). It runs on an EC2 instance and is configured using OpsWorks.
Today it's not working, and I see in OpsWorks that the instance is showing as setup_failed.
According to the logs it fails here:
[2021-07-02T15:00:59+00:00] FATAL: Stacktrace dumped to /var/chef/runs/18bc4301-71c1-4393-bb26-eae958791d5a/local-mode-cache/cache/chef-stacktrace.out
[2021-07-02T15:00:59+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2021-07-02T15:00:59+00:00] ERROR: deploy_branch[/srv/api] (iparcelbox::deploy-api line 45) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '255'
---- Begin output of git fetch origin ----
STDOUT:
STDERR: error: cannot open .git/FETCH_HEAD: Permission denied
---- End output of git fetch origin ----
Ran git fetch origin returned 255
I've checked the recipe file for iparcelbox::deploy-api and line 45 calls a deploy_branch:
deploy_branch server_path do
user userName
group groupName
repository node[:iparcelbox][:git_url]
revision node[:iparcelbox][:revision]
enable_submodules false
migrate false
shallow_clone true
git_ssh_wrapper "/tmp/api_git_wrapper.sh"
rollback_on_error false
keep_releases 5
symlink_before_migrate.clear
purge_before_symlink purge_dirs
create_dirs_before_symlink []
symlinks({})
action :deploy
end
So as I understand it, the deploy_branch is trying to fetch a git repo, and for some reason it's failing? I've checked my GitHub repository for the source files and I can see an ssh 'Deploy Key' which is showing as used within the last week.
If anyone could give me any suggestions as to what else to try, it would be much appreciated!
I found an answer to this - I thought the issue was permission denied accessing the git repository, but actually it was because the destination folder on my instance had modified ownership. Setting the ownership back to that specified in the Chef recipe using chown allowed the setup to complete successfully.

Can not solve Git error "refusing to merge unrelated histories"

When I tried to pull
git pull https://myid#bitbucket.org/myid/abc.git
error occurred
branch HEAD -> FETCH_HEAD
fatal: refusing to merge unrelated histories
Then I tried this
git pull origin master --allow-unrelated-histories
error occurred
fatal: 'origin' does not appear to be a git repository fatal: Could
not read from remote repository.
Then I tried this
git mergetool
error occurred
This message is displayed because 'merge.tool' is not configured. See
'git mergetool --tool-help' or 'git help config' for more details.
'git mergetool' will now attempt to use one of the following tools:
tortoisemerge emerge vimdiff No files need merging
Check branch name
git branch --contains=HEAD
branch is only master
master
I can not figure out how to fix this problem, please teach me what I can do next??

fatal: destination path '.' already exists and is not an empty directory

I'm getting this error when I try to git clone my Bitbucket repo from my remote Digital Ocean server. The server directory I'm trying to clone the repo into is not empty, as I'm setting up my Django project in it (env, static, manage.py etc are all in there). So how do I clone the repo into this directory that is not empty?
I've already tried a reccommended answer which said use git fetch and git checkout -t origin/master -f - and that didn't work - I got this error:
fatal: A branch named 'master' already exists
Any suggestions what I can do?
If I understand well, you have a folder in which you already have files that will be part of what you will clone.
What you can do is :
Initialize your folder as a GIT repository
git init
Stash all your files in your folder
git stash save -u
Add your remote repository URL
git remote add myremotepository git#github.com:X/Y.git
Pull the stuff :)
git pull myremoterepository master
Reapply the files you stashed
git stash pop (or git stash apply if you want them to still be in the stash memory)
Make sure the name of the project on your computer is different from the repo name. If they are the same, cloning will be impossible. E.g you could name your repo as project_java and the actual name of the project on your computer could be project