I have a GitHub repository that is out of sync with the code on my desktop (see attachment 1). So I need to push my desktop code to GitHub. I found this article: https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/How-to-git-push-an-existing-project-to-Bitbucket. In GitHub Desktop I opened 'Repository --> Open in Command Prompt' and performed the following:
cd D:\Award Tracking Application - restart 20240407\Award Tracking Application
D:
git init
git add .
git config --global user.email "xxxxxxxxxx@xxxxxl.com"
git config --global user.name "xxxxxxxxxxxr"
git commit -m "Add files to git before the Bitbucket push."
git remote add source https://Glyndwr@bitbucket.org/ATA_Team/gmat.git
git push -u -f bitbucket master
The push returned an error:
fatal: 'bitbucket' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
So I returned to the GitHub Desktop to do the push (see attachment 2). However, that gave an error message that I needed to perform a fetch first (see attachment 3). So I clicked on "Fetch". Then retried the Publish. However the same error message that I needed to perform a fetch first is displayed.
I have checked the repository and the files that I need uploading from my desktop are not there.
Hello @Glyndwr and thank you for reaching out to the Community.
It seems there are a few potential issues here, so let's address them individually :
1. The remote and push commands do not match
You attempted to add the remote repository using the command
git remote add source https://<username>@bitbucket.org/<workspace>/<repository>.git
and then you tried to push to 'bitbucket' which does not exist as per the commands you executed.
git push -u -f bitbucket master
The remote name you have added is 'source', not 'bitbucket'. If you want to push to this remote, you should use the command
git push -u -f source master
2. Error message "fatal: 'bitbucket' does not appear to be a git repository":
This error message is indicating that git can't find a repository at the location you've specified. This could be due to a few reasons, maybe a typo in the URL or perhaps the repository doesn't exist.
3. GitHub Desktop asking to fetch before the push
This is because your local copy of the repository doesn't have the latest changes from the remote repository. Fetching will update your local copy with these changes.
If after fetching, you're still seeing this error message, it's possible that there's a conflict between your local and remote repositories that needs to be resolved. This could occur if changes have been made to the remote repository that conflict with the changes you're trying to push.
In this scenario, you would need to pull the changes from the remote repository, resolve any conflicts, commit the resolved changes, and then push your commit to the remote repository.
Here's the sequence of commands you would use to do this:
1. Pull the latest changes from your 'source' remote repository's 'master' branch.
git pull source master
2. If conflicts are present, open the conflicting files and resolve the differences.
3. Stage all your resolved changes.
git add .
4. Commit your resolved changes.
git commit -m "Resolved merge conflicts"
5. Push your commit to master branch of the 'source' remote repository:
git push source master
Hope that helps! If you have any questions, feel free to ask.
Thank you, @Glyndwr !
Patrik S
You're very welcome! Feel free to reach out to community if you ever need help :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.