How to push changes to old repo to GITHUB after downloading it - github

I lost my PC data after hard-drive corruption. After that from my github repo i downloaded my code and made some changes and did npm install, but when i tried to push my changes to repo, it is saying there are no currently active repo to push.
How to push my new changes to my old repo?

You should have cloned the repo on your local machine, that way you would have the git initialized. But, for now, you can follow the below steps.
git init
git remote add origin <github repo url>
The first line would initialize the git repo and the second would point it to the online repo you already have.

You could have downloaded the repo with:
git clone <repo url>
but to answer your question:
git init
git add .
git commit -m "init"
git remote add origin <repo url>
you can then verify the remote url with:
git remote -v
after that check If your .gitignore file is there, if not create one and add node_modules/
after that just push it with:
git push -f origin master

just check whether you have set the remote origin correctly.
$ git remote show origin
$ git remote -v
use the above commands to check your remote URL. if it is not set correctly, set the URL again.
$ git remote set-url < your repo URL here >
hope this will work

Related

GitHub - failed to create remote repository

I have a repository- 'repo1' in our company's GitHub cloud.
git remote -v, shows -
origin git#github.****:***/repo1.git (fetch)
origin git#github.****:***/repo1.git (push)
Now I am trying to add a new remote repo - 'repo2' with the command line:
projectName=repo2
mkdir $projectName
cd $projectName
git init -b $projectName
touch README.md
git add README.md
git commit -m 'Initial commit'
git remote add origin ****:***/repo2.git
git push -u origin $projectName
and I get an error in the last command:
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
It is worth emphasizing that the repo was created with local success.
also, git remote -v, shows
origin git#github.****:***/repo2.git (fetch)
origin git#github.****:***/repo2.git (push)
but failed to push to remote.
also is worth emphasizing, that I could add a new repo in our GitHub site. The only problem occurs when adding from the terminal.
I found on GitHub forums, that the new repo must be created on GitHub site before doing the git push

Git push creates my project folder inside another folder, how to avoid it?

I have been creating some repositories of my projects since the terminal and everything was good, but recently I tried to push a project to GitHub and but another folders are created.
For example, the path of my project folder is /Desktop/Programming_course/React_Native/robotreact.
So, since the terminal I go to the path of my Project robotreact and I run:
git add .
git commit -m "first commit"
Then, in GitHub, I create my repository and after that I run:
git remote add origin https://github.com/Josesosa0777/robotreact.git
when I push it running: git push -u origin main
In my GitHub are created other folders:
How can I avoid those extra folders?
It seems like if another project is added, I am not sure if the problem is about a SSH key, I dont know how to solve it, any idea?
That means you have initialized your Git repository in / instead of /Desktop/Programming_course/React_Native/robotreact: check for /.git
If that is the case, and you don't have many commits, you can simply:
delete /.git
initialize the repository in the right folder,
add the remote origin
add files, commit and push
That is:
cd /Desktop/Programming_course/React_Native/robotreact
git init .
git remote add origin https://github.com/Josesosa0777/robotreact.git
# check your user.name/user.email
git config user.name
git config user.email
git add .
git commit -m "First import"
git push -u origin main
If your local branch is master:
git push -u origin master:main

How to commit code to GitHub on Android through termux app

Please I would appreciate if anyone can drop a direct link to the termux commands used to create repos,commit code and delete them on GitHub through termux terminal,all I have seen through numerous Google searches are only how to install them,I also don't know how to navigate to a certain file or directory.
First of all you have to install git in termux pkg install git . then go to the directory where your code have with cd <name of your directory>
If you want to create a git repository use git init.
then add the files to git
git add <file name> OR add all files in the directory git add .
First commit after installing git you have to specify who you are
git config --global user.name "<Your Name>"
git config --global user.email "<your_email#whatever.com>"
then commit the code with
git commit -m "<commit message>"
commit message is what changes you done in this commit
you have to create a reposityory in github github.com/new
and add github reposityory url to git git remote add origin https://github.com/<github username>/<github repository name>.git
then push the repository to github. git push -u origin master
-u means seting upstream as default. after that just git push
have some reference of tutorials about git
learnxinyminutes, githowto

How to delete GitHub blame history?

I'd like to delete the GitHub blame history that GitHub shows (tracking all changes made)
I am aware of how to how to roll back changes, but I am not trying to roll back any changes I have made, I am simply trying to delete this history of the changes.
Obviously, I do own the repository that I will be operating on (and am the sole owner)
If this is for all files of your GitHub repository, the simplest way would be to:
initialize a new local repository
add files from the original repo
add as remote the original repo GitHub URL
force push
That is:
git clone https://github.com/me/myrepo
git init myrepo2
cd repo2
git --work-tree=../myrepo add .
git checkout # -- .
git commit -m "Import myrepo"
git remote add origin https://github.com/me/myrepo
git push --force -u origin master

Push an existing repository when creating a new repository always fail?

So every time I try to create a new repository and follow the Github instruction here.
…or push an existing repository from the command line
git remote add origin
https://github.com/menghaohsu/JavaAkkaCountWordInDirectory.git
git push -u origin master
It doesn't push the file in JavaAkkaCountWordInDirectory to Github but push repository. Can anyone help me with this?
Let me give you a few steps over here.
I assume you created your repo via GitHub.com web interface.
Locally you should have done all of the following steps prior to pushing the files to the remote.
git init --> This will initialize your local repo
git remote add origin {remote address}
git add {filename here | . } --> With this you add the file(s) to the staging area
git commit --> This command commits your changes (You have to add a message)
git -u push origin master
That should do the trick