Angular-cli gitpages deployment deleted my local project, and didn't deploy - angularjs

Per: https://github.com/angular/angular-cli#deploying-the-app-via-github-pages
I ran this initially and it wouldn't work. So I ran:
git add .
git commit -m "Initial deployment"
Then ran:
ng github-pages:deploy --user-page --message "Optional commit message"
It went through a number of steps, and I created the GitHub token and fed it the token. Then it asked for my username, and then it spit out:
Command failed: C:\Windows\system32\cmd.exe /s /c "git clean -f -d"
warning: failed to remove src/app
warning: failed to remove src/assets
There was a permissions error during git file operations, please close any project files/folders and try again. You might also need to return to the master branch manually.
After that, poof, all files gone except for those folders. Also, nothing was uploaded to github.
Fortunately I didn't work a ton on this particular project, but curious as to what I did wrong.

Related

Can not deploy create-react-app with token

I have been trying to deploy create-react-app, but got an error
fatal: repository 'https://github.com/charyyev2000/Portfolio-React.git/' not found
then I created a token and tried to deploy with that,
git remote add origin https://<TOKEN>#github.com/charyyev2000/Portfolio-React.git
again got an error;
Deleted repository, created again and tried to deploy, again got the same error
fatal: repository 'https://github.com/charyyev2000/Portfolio-React.git/' not found
What did I do wrong? or, is there something wrong with my homepage in packages.json?
"homepage": "https://charyyev2000.github.io/Portfolio-React",
I cant deploy from any other of my repositories too.
What should I do now.
You are new comer in Git/GitHub tools, I hope you can done this task.
Your remote repository URL is https://github.com/charyyev2000/Portfolio-React
Solution 1:
Create a new repository on the command line
echo "# Portfolio-React" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/charyyev2000/Portfolio-React.git
git push -u origin main
Solution 2: (I think you will prefer this solution, because your source code is exist).
Push an existing repository from the command line
git remote add origin https://github.com/charyyev2000/Portfolio-React.git
git branch -M main
git push -u origin main
Let's follow the guide what you see likes this
P/S: Sometime, you need
git add .
git commit -m"foo"
git push -v
or you see any guide on your console screen, let's follow guide what you see.
Your repository is probably private.
Try this: git remote set-url origin https://YOUR_GITHUB_USER#github.com/charyyev2000/Portfolio-React.git
Or use an ssh key.
https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent&ved=2ahUKEwjoysreiIjzAhVwTTABHQPHDzIQFnoECGwQAQ&sqi=2&usg=AOvVaw2B_nuIizqk0LtbV4qWtzzH

Removing a file in Git repo but file doesn't exist

In committing and pushing to my repo, I get the following error:
The issue is that I've already manually deleted the video file. The video does not exist anywhere in my repo.
I also tried to
git rm src/assets/video/Greensleeves and it says fatal: pathspec src/assets/video/Greensleeves did not match any files.
How can I get passed this so that I can commit/push?
Try and apply the new git filter-repo, which does replace the old git filter-branch or BFG.
It has many usage examples, including path-based filtering, in order for you to remote the src/assets/video/Greensleeves file in past commits:
To keep all files except these paths, just add --invert-paths:
git filter-repo --path src/assets/video/Greensleeves --invert-paths
Then git push --force (that does rewrite the history of your repository, so make sure to notify any other collaborator)
Since it must be done on a fresh clone:
Don't touch anything to your current clone folder
Create a separate clone of the repository, where you do the filter repo
In that second clone, now cleaned (no more big file in its history), import your work from your first repo
That is, for point 3:
cd /path/to/second/clone
git --work-tree=/path/to/first/original/clone add .
git commit -m "Import work from first clone"
git push --force

fatal: in unpopulated submodule

I am quite new to github and I am trying to find a solution to a current problem that I am having. I will go through my process step by step:
First I created a new folder named [project name]
Next I used these commands:
cd [project name]
git clone [remote project from github url]
So far I have created a folder and cloned a project that my group is working on in github.
Next, I went inside that folder and created an angular project with
ng new [angulartest]
This will create all the components of my angular test into the same folder that is the clone of the one from github.
Finally, I pushed the new angular test on github with
git add [angulartest]
git commit
git push
What happens is that it only pushes the folder [angulartest] but none of its contents (even though there are contents in it). When I try to pull from its contents, I still just get an empty folder in return.
When I try to enter that folder and add each element of the contents, using these steps:
cd [angulartest]
git add e2e, src, nodemodules, etc
git commit
git push
It gives me the following error (even when I try to add each element individually):
fatal: in unpopulated submodule [angulartest]
I was wondering if it was a problem with my git syntax, the angular project, or the way I tried to clone the project. That way, I know which direction I want to be headed when looking for a solution.
It seems like, you may have removed the .git folder. In that case you can try
git rm --cached angulartest -f
git rm --cached . -rf
Stealing from anlijudavid's comment which was the actual answer for me on macOS with zsh.
Adding -r based on Richard Collette's comment to this answer.
The root cause of this error in my case was that I have a subdirectory with its own .git folder inside. When I issued the git add --all command, I got this same error
Here's how I resolved the issue
Remove all .git folder inside the sub directory causing the error
cd to the main directory
git rm --cached sub_directory_name -f
git add --all to add the subdirectory and contents, recursively
git status to verify that the items are added
I almost got a headache with this error but thanks for the previous answers, a combination of those worked for me.
Here's what I did
Make a copy of the 'submodule' directory somewhere outside of the repository (e.g. your desktop)
Delete the submodule directory from your repo
Commit the repo
Go into the copy you made of your submodule directory, delete .gitignore file and .git directory
Copy the submodule directory back into your repo and commit
This meant I lost the commit history of the submodule but at least it fixed the issue of my files in the submodule not going to git!
If we cloned from third party repository we got this " fatal: in unpopulated submodule 'submodule name' " error.
This error fix for me using
git rm --cached <submodule name> -f
Also you can remove .git folder manually then you can try to git add
I got the same error when I had a subdirectory in my local repo, had deleted the .git to solve different issue, and then tried to add an updated html file to my repo.
I went to github and uploaded the file using their GUI. Now I can see that everyhting matches and git status shows no issues.
Had the same issue when trying to push a new react-app folder to git.
Unfortanately, I overlooked the ".gitignore" files in the folders.
First check for files:
find | grep -w ".gitignore" | xargs ls -lh
After that:
find | grep -w ".gitignore" | xargs rm -fr

Escape the colon from a command so it's not render like a label in batch files

I'll make a bat file with goes deploy my site on GitHub pages. The repository is heinpauwelyn.github.io and is made with Angular-CLI. To deploy the site I could use this command:
ng github-pages:deploy
This will place everything on the gh-pages branch but it must stand on the master branch! I'm developing on the development branch.
To automate the proceedings of committing, deploying, checkout gh-pages, copy-pasting, checkout master, copy-pasting, committing and checkout development, I've create this bat file named deploy.bat:
git status
git add *
git commit -m "deploy"
git pull
git push
ng github-pages:deploy
git checkout gh-pages
echo "copy all your files in this folder to a temporary folder outside this repository (except these inside the `.gitignore` file)"
pause
rem must be automatic done by using this xcopy . ..\temp
git checkout master
echo "copy all your file form the temporary folder back into the repository"
pause
rem rmdir /s /q .
rem xcopy ..\temp .
git status
git add *
git commit -m "deploy"
git pull
git push
echo "site is deployed!"
git checkout development
The code will stop on this line: ng github-pages:deploy. I've checked the syntax on Wikipedia and have seen that the colon is a label to skip code from a running batch file. I think this colon gives the bug.
My question is now can I escape the colon from the batch file so that it's not longer a label but a command?
Note
The goal of the batch file is that I just must use one command to deploy my full site. In the package.json file of my project, I use this code:
{
"scripts": {
"deploy": "deploy.bat"
}
}
When the bug will be solved, I just use command below to deploy my site on the master branch.
npm run deploy
It wasn't the colon that gives the bug but because ng is a batch file. Helped answer: Azure Function / Azure Website Custom Deploy Script Ending Prematurely.
After searching and asking this question, I've found the solution that works!
git status
git add *
git commit -m "deploy"
git pull
git push
call ng.cmd "github-pages:deploy"
call git checkout master
call git merge origin/gh-pages --allow-unrelated-histories
dployer.exe rem | This is a little executable file I've written (it's just for changing
rem | content of some files)
git add *
git commit -m "deploy bug oke"
git pull
git push
git checkout development
Thanks to #MCND, #Mofi and #SomethingDark for the comments 😃!

Push changes to bitbucket using atom

I am using the text editor Atom and it should be possible to upload directly to bitbucket from atom. I found a thread here on stackoverflow someone asked for this and someone recommended git-plus package. I did download this package but it tells me i need to edit user.email and user.name variable in gitconfig file. But it doesnt say anywhere where i can find this gitconfig file. I found a few config files but none of them have these variables. Is this gitconfig file in my .git folder in my project or is it somewhere in atom? I hope someone here can help me with this
Set up git in your shell to use bitbucket as the remote repo.
You will first need to sort that basic Git config thing about the emails:
$ git config --global --get user.name
Your Name Here
$ git config --global --get user.email
your_email#someplace.com
If you don't have these values already added, then simply add them. Put your current directory someplace under the root of your atom repository (or, if you want to use the --global parameters [recommended]), then anywhere will do, really so long as it's your login you're working with.)
$ git config [--global] user.name "Your Name"
$ git config [--global] user.email "your_email#somplace.com"
First set up your ssh key so you don't have to type your password on every command. Once that's done, then go to the Git repo you set up for your Atom project. Most likely that's in the top level of my project. Go there and...
$ git remote -v
$ git remote add origin git#bitbucket.org:youruid/yourrepo.git
Now try it from the shell to make sure all is working:
$ git push
It's very likely you'll get a message similar to:
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
Follow the advice given, then, if you're feeling particularly paranoid, make a change to any file in the repo -- using atom if you like, doesn't matter -- and try it all again:
$ git add -u
$ git commit [-v]
...
$ git push
This time, it should go off without a hitch.
Now back to atom...
If you've configured things there so that atom can access your Git repo locally, there should now be a Fetch widget in the lower right corner:
If you make a change now in atom, you'll see this change to Push... with the functionality to match.
The GitHub widget still doesn't do anything -- which is mildly annoying -- but I believe you might be able to find an atom package out there that does similar things.

Resources