Deleted github repo still connected to local files in terminal - windows

I tried to push a project that I'd made locally to github and there was an error since I had created a repo on github with a license instead of leaving it empty. When I attempted to push the current local save to the remote repo, git bash would say there was nothing to commit, working tree clean even though the repo was empty save for the license and the local project was full of files.
I deleted the repo on github, but git bash still says (main) when I pull up the project. I normally start the repo on github and then git clone, and this is my first time trying to go the opposite way.
I deleted the original remote repo that the project was supposed to be for, and made a new one that is completely empty. I tried
git remote add origin git#github.com:manyLizards/node-tutorial.git;
error: remote origin already exists.
HP#DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git branch -M main
HP#DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git push -u origin main
Enter passphrase for key '/c/Users/HP/.ssh/id_ed25519':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 1.75 KiB | 1.75 MiB/s, done.
Total 5 (delta 0), reused 5 (delta 0), pack-reused 0
To github.com:manyLizards/node-tutorial.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.
HP#DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git add -A
HP#DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git commit -m"initialized github repo"
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree clean
HP#DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git push origin --delete main
Enter passphrase for key '/c/Users/HP/.ssh/id_ed25519':
To github.com:manyLizards/node-tutorial.git
! [remote rejected] main (refusing to delete the current branch: refs/heads/main)
error: failed to push some refs to 'github.com:manyLizards/node-tutorial.git'
HP#DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git branch --delete --remotes origin/branch-name
error: remote-tracking branch 'origin/branch-name' not found.
HP#DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git branch --delete --remotes origin/main
Deleted remote-tracking branch origin/main (was dba3d90).
HP#DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git fetch origin --prune
Enter passphrase for key '/c/Users/HP/.ssh/id_ed25519':
From github.com:manyLizards/node-tutorial
* [new branch] main -> origin/main`

I assume you don't need to make a copy of your remote since you already have deleted that. Run
git remote remove origin
which removes the origin, in your case main. Also, you can change the URLs in .git\config to set for new URLs without removing the remote repo.
see hobbs's answer

Related

Not able to redeploy the app after upgrading the heroku stack

We are in process of upgrading the heroku stack from 18 to 22. After clicking on upgrade while we are trying to redeploy the app we are getting the below error while doing git push:
error: src refspec master does not match any
error: failed to push some refs to 'https://git.heroku.com/test.git'
We are following the below steps to redeploy:
$ heroku git:clone -a test
$ cd test
$ git add .
$ git commit -am "make it better"
$ git push heroku master
Also we have followed the below steps from CLI as well
To upgrade via the Heroku CLI, use the stack:set command on your production app:
heroku stack:set heroku-22 -a test
Setting stack to heroku-22... done
You will need to redeploy ⬢ for the change to take effect.
Run git push heroku main to trigger a new build on ⬢ .
git commit --allow-empty -m "Upgrading to heroku-22"
[master (root-commit) 89fea09] Upgrading to heroku-22
git push heroku master
Enumerating objects: 2, done.
Counting objects: 100% (2/2), done.
Writing objects: 100% (2/2), 185 bytes | 185.00 KiB/s, done.
Total 2 (delta 0), reused 0 (delta 0), pack-reused 0
remote: error: pathspec '.' did not match any file(s) known to git.
remote:
remote: ! Heroku Git error, please try again shortly.
remote: ! See http://status.heroku.com for current Heroku platform status.
remote: ! If the problem persists, please open a ticket
remote: ! on https://help.heroku.com/tickets/new
remote:
To https://git.heroku.com/test.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/test.git'
bhattacharjee.c#bhattac-ltmynzq ei-mule-dashboard-ee1 % git push heroku main
error: src refspec main does not match any
error: failed to push some refs to 'https://git.heroku.com/test.git'.
We are getting the below error here:
remote: error: pathspec '.' did not match any file(s) known to git.
remote:
remote: ! Heroku Git error, please try again shortly.
remote: ! See http://status.heroku.com for current Heroku platform status.
remote: ! If the problem persists, please open a ticket
remote: ! on https://help.heroku.com/tickets/new
remote:
To https://git.heroku.com/test.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/test.git'
bhattacharjee.c#bhattac-ltmynzq ei-mule-dashboard-ee1 % git push heroku main
error: src refspec main does not match any
error: failed to push some refs to 'https://git.heroku.com/test.git'.
Could you please help us in resloving the issue.
We are following the below steps to redeploy:
$ heroku git:clone -a test
First of all, you shouldn't be doing this:
A Heroku app’s Git repository is intended for deployment purposes only. Cloning from this repository is not officially supported as a feature and should be attempted only as a last resort. Do not use this repository as your app’s canonical “origin” repository. Instead, use your own Git server or a version control service such as GitHub.
If this is part of your regular workflow, please adjust accordingly. Heroku is not a source code management platform.
Now, onto the problem:
src refspec master does not match any
You simply don't have a master branch.
Heroku builds from one of two branches: main (which is newer and slowly becoming the community standard default branch name) and master (legacy).
If you don't have a master branch, you almost certainly have a main branch that Heroku will happy build from:
git push heroku main
If you need to deploy from some other branch another-branch, you still need to push to main (or master) on Heroku:
git push heroku another-branch:main
Finally, please don't actually use "make it better" as a commit message. Spend some time making commit messages clear and meaningful. There is lots of good advice floating around about how you can do that.

Git Files not being pushed to remote repository [Windows]

So I'm just learning Git, and can't tell what I'm doing wrong in setting up a local and remote repo for my scripts. Originally, the remote repo was going to live on a fileshare (\server\share$\scripts), but I can't even seem to get this to work on my local machine.
I've done my research, and read up on some of the common pitfalls, but I still can't seem to get files accurately reflected in my remote repo when pushing from the local one.
What I have:
Local Repo: In C:\git, with one file "test.txt" created by:
cd C:\git
git init
echo "Hello World" > test.txt
git add .
git commit
Remote Repo: C:\test
git --bare init
Then, when I specify a remove branch with:
git remote add origin C:\test
git push origin master
It tells me all is fine:
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 315 bytes | 315.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To C:\test
06e076a..62b6130 master -> master
And further git pushes return "Everything up-to-date", but the files are never pushed to the remote repository. Querying the logfile indicates that the push did in fact take place:
commit 62b6130cedef529ef97aec5333fcbee96c5e9a2f (HEAD -> master)
Author: [Redacted]
Date: Wed Jan 24 15:21:37 2018 -0500
TEST COMMIT
So where are the files? I'm on the right branch (master), and I even ran a git config receive.denyCurrentBranch false because some other similar threads suggested this as a fix.
Looking for some guidance here, appreciate any and all help!
Your remote repository is a bare repository. This means there simply is no checked out working tree. Just the git objects and branches and tags.
Having a working tree (aka your files in the most up to date master branch) doesn't make any sense for a remote repository. This is where you store all versions of all your files in one place. How should git know which branch/version/commit to use in the working tree?
I also found this description: Source
git init is for working
git init --bare is for sharing
To get your files back again, you need to clone from there.
git clone C:\test .
This will create a new repository with working tree.
Here are some links:
What's the -practical- difference between a Bare and non-Bare repository?
http://bare-vs-nonbare.gitrecipes.de/

Why do I sometimes get mergeconflicts on pulling but trying again works?

I created a new file in a local folder monitored by git. I then did
git add .
git commit -m "blah blah"
git push
but was rejected with
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
I tried git pull and got the error
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
which is a bit surprising considering there is only the master branch.
So I tried git pull origin master and something looking like VI with a bunch of empty lines opened up wanting me to resolve merge conflicts and it didn't give any information.
I just want to push changes to the repo. I'm the only one working on this personal project. I'm using Windows 10 and the official git bash. How do I git over this problem?
BUT WAIT!
I tried git pull origin master a second time and it worked! Nothing had been changed. This has happened before and I'd like to know why?
Here's the details:
first git pull origin master gave
* branch master -> FETCH_HEAD
second:
branch master -> FETCH_HEAD
Already up-to-date.
third:
remote: Resolving deltas: 100% (2/2), completed with 1 local objects.
no other commands were run in between. On the first one a bizarre VIM text editor opened up that wanted me to type something in.
remote: Resolving deltas: 100% (2/2), completed with 1 local objects.

Push on gerrit with windows

I am struggling to push some of my data to a gerrit with TortoiseGit. I created a new repo and committed it to the master. I added one remote, with my private key and I also uploaded the public key.
Pulling from the gerrit is no problem, but when I try to push the following error occurs:
remote: Resolving deltas: 100% (96/96)
remote: Processing changes: refs: 1, done
remote: ERROR: missing Change-Id in commit message
remote: Suggestion for commit message:
remote: Initial Commit
remote:
remote: Change-Id: Icb5f79b9a32abc77a99f0034ecc6a5a9ae9ef1c6
remote: Hint: To automatically add a Change-Id to commit messages, install the commit-msg hook:
remote: $ scp -p -P 29418 <server stuff>:hooks/commit-msg .git/hooks/
The big problem is, I am living in a windows world, where is no $ scp .... any suggestions, how I can install git hook or delivering a commit id?
Btw git hooks --install returns 'hooks' is not a git command
Just download it from : http://www.example.com/r/tools/hooks/commit-msg and then copy it to your .git/hooks folder.
Or you can download it from gerrit review
-- Update --
If you add the commit hook after making the commit locally, which is probably the case, you need to amend your last commit. Simply amending the last commit without making any real change will add the Change-ID to your log message.
git commit -a --amend
git log -1 // this is to check that the Change-ID is present in your log message
git push origin HEAD:refs/for/master
-- Update 2 --
If you are like me and have a lot of projects at create clones every now and then you might want to setup your git installation so the commit-msg hook is installed by default. You can do this by copying the commit-msg to your git template folder. On my Win7 system it can be found here:
C:\Program Files (x86)\Git\share\git-core\templates\hooks
The next time you create a new clone you do not need to download the commit-msg again.
This looks like a case of appropriate hooks not downloaded into your clone.
You can try doing this:
# cd into your clone such that you should be able to see .git folder on ls -a
# for example if you had following structure myclone/myproject/.git
# you have to cd to myclone/myproject directory
$ scp -p -P 29418 <server stuff>:hooks/commit-msg .git/hooks/
Now go to your hooks folder and do ls to see if you have required hooks downloaded.
You don't install any hooks you just copy it from your gerrit repo
Update
https://www.mediawiki.org/wiki/Talk:Gerrit/git-review
is what you are perhaps looking for

Cannot push to remote git repository

So I have been having troubles pushing my most recent commits to a remote repository that I have set up on Bitbucket.
I am originally using Xcode, and have asked this question and was recommended to use terminal to push instead of Xcode.
Now, I tried terminal but that did not solve the problem. But it did give me a more detailed error message when I try git push
Neils-iMac:ProjectName Neil$ git push
Password:
Counting objects: 49, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (38/38), done.
Writing objects: 100% (39/39), 975.78 KiB, done.
Total 39 (delta 31), reused 0 (delta 0)
error: RPC failed; result=55, HTTP code = 0
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
fatal: expected ok/error, helper said '2004\??? ?&?ЇҶ-9?u?r?m?v?ǣ3Ƅ:??Eƒ?=?&?"d?+??
*^?eA??/3cv????ʞe??f???????
?(??`}D???5???^:T??PxP????%?338?]??F?}???Gf?g??[??*??}zƈ1X'
Neils-iMac:ProjectName Neil$
Neils-iMac:ProjectName Neil$
I am new to these remote repositories, and had everything working fine on Xcode, so if you recommend for me to do something in terminal it would help if you described how to do so.
See my previous question for a bit more detail.
EDIT: This is the result of;
git status:
# On branch master
# Your branch is ahead of 'origin/master' by 5 commits.
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# CrunchCalculator.xcodeproj/project.xcworkspace/
# CrunchCalculator.xcodeproj/xcuserdata/
nothing added to commit but untracked files present (use "git add" to track)
git remote show origin:
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (fast-forwardable)
Looks like you are trying to push a large delta and your push buffer is not big enough
Try this:
git config http.postBuffer 524288000
I had the same problem and git config http.postBuffer 524288000 worked for me.

Resources