Folder's content are empty after pushing into bitbucket - gitlab

I wanted to push folders from my local repositories into bit bucket. Somehow I was unable to do that.
I got the solution somewhere to use
$ git push -f origin master
which resolved the issue but erased all lines of code.
This is my very first use of bit bucket. How to get all content back?
Now, I deleted previous repository and created the new one. Typed below but getting error
$ git remote add origin
https://PoojaThapa#bitbucket.org/PoojaThapa/git-poojatest.git
fatal: remote origin already exists.
$ git push origin
fatal: HttpRequestException encountered.
An error occurred while sending the request.
remote: Not Found
fatal: repository 'https://PoojaThapa#bitbucket.org/PoojaThapa/git-
test.git/' not found
please suggest.

Assuming you have a repository in your current directory you can add a remote with any name using:
git remote add <remote-name> <url>
You are getting an error with your first command because a remote already exists called origin.
Try git remote -v to see which remotes you have already got defined.
In your case I think you want to create a new remote (with a different name, for example bitbucket), so
git remote add bitbucket https://PoojaThapa#bitbucket.org/PoojaThapa/git-poojatest.git
Verify that the remote was created correctly using git remote -v, then you can push to the new remote using <remote-name>/<branch>:
git push bitbucket/master

"repository not found" implies that the origin URL is incorrect. List your current remotes with git remote -v, and double-check that you have the correct URL(s) listed. (You should be able to go to the URL in your browser.)
If something is incorrect, you can fix it with git remote set-url origin correct-url-goes-here.

Related

Gitlab pushing first project failed due to could not read from remote repository

I was new to Gitlab was trying to push my project from local machine to Gitlab.
Have done the SSH key and followed the instructions at Gitlab. Done the Git global setup. Was trying to add an existing folder , so i followed the instructions listed
cd existing_folder
git init
git remote add origin https://gitlab.com/sss/testnode.git
git add .
git commit -m "Initial commit"
git push -u origin master
but failed at the last step at the git push. The error message was
Tried adding the remote origin, but it was told it already exists. So not sure where it went wrong. Please help, much appreciated :)
Have done the SSH key
The problem is that you have defined your origin as HTTPS, not SSH.
Try:
git remote set-url origin git#gitlab.com:sss/testnode.git
That will override origin URL.
Independently, make sure your SSH key does work and allows GitLab to authenticate you as your GitLab account with:
ssh -T git#gitlab.com
Check out your credentials, if they are invalid, it wont give u to upload changes.
For Windows check this: https://www.digitalcitizen.life/credential-manager-where-windows-stores-passwords-other-login-details
For Linux check this: https://askubuntu.com/questions/30907/password-management-applications (if you do not know how to change credentials via terminal)

git pull with access token, git push with username / password

I've got a problem with git push. Here are many threads regarding this issue, but none of them fit to my problem.
The company I work for, has it's own gitlab. Policy is only https, no ssh is allowed. For cloning and pulling, an access token is required. Pushing only with username/password. Don't ask me about the underlaying reason. Unfortunately I don't know it.
Error message is:
$ git push
fatal: unable to access 'https://<username>:<AccessToken>#<domain>/<owner>/<reponame>.git/': The requested URL returned error: 403
At least I alread was able to clone a repo, but I'm failing to push the changed content respectively. Ubuntu 18.04 is running on my laptop.
What do I need to do to solve my issue?
You already know that every remote stores a URL: origin literally means https://<username>:<AccessToken>#<domain>/<owner>/<reponame>.git/.
What you didn't know is that every remote actually stores two URLs. One is used for git fetch, and the second one is used for push. The second URL defaults to being the same as the first URL, but if you set it, you can set it to anything else, such as the URL without the access token. To set the second URL, you can use git remote set-url --push:
git remote set-url --push origin <url>
If you're like me, you might want to know about git config --edit as well, which will open the configuration file (typically just .git/config) in the same editor you're having Git use for everything else, where you can just edit it directly. But git remote is the tool designed for fiddling with the settings attached to each remote-name.

Bitbucket git issue on Linux

I am very new to bitbucket and linux. I am trying to upload files from my local to bitbucket. I tried the following command:
git commit -m 'commit to master'
git push -u origin 'master'
Then I got an error like
fatal: 'origin' 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.
Then I tried
git remote add origin ssh://mjsofttechindia#bitbucket.org:mjsofttechindia/project.git
git push origin master
Then I got an error like
ssh: Could not resolve hostname
bitbucket.org:yourname: Name or service not known fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
Please help. I don't know if this is correct or not. Please help me.
Change remote url to
ssh://mjsofttechindia#bitbucket.org/mjsofttechindia/project.git
git remote set-url origin ssh://mjsofttechindia#bitbucket.org/mjsofttechindia/project.git
Then you have to configure your name and email address (the one that you created your Bitbucket account with) in your local repository
git config user.name "Your Name"
git config user.email "you#email.com"
Then do a push again
git push -u origin master

GIthub repository not found error on Android Studio 2.1.2 after changing the repository

I delete my old Github Repository (name: RealmDemo) and create the new repo with new name: daftar-negatif-investasi. I'm on Windows 10 and I have removed the old remote repository and added the new one using the following command (using Git Bash):
git remote rm origin
git remote add https://github.com/masumo/daftar-negatif-investasi.git
But, Android Studio always give me this error message:
Failed with error: fatal: repository
'https://github.com/masumo/RealmDemo.git/' not found
when I try to push into my Github repository.
I believe the remote repository already changed, because running git remote -v command give me this result:
origin https://github.com/masumo/daftar-negatif-investasi.git (fetch)
origin https://github.com/masumo/daftar-negatif-investasi.git (push)
It seems Android Studio still refers to the old repository. Any solutions for this problem?
Try this:
Open the /.git/config file and delete the lines:
[remote "origin"]
url = https://github.com/githubaccountname/MyProject.git
fetch = +refs/heads/*:refs/remotes/origin/*
git remote rm origin
git remote add origin git#github.com:username/MyApplication.git
git push -u origin master
Then it should work.
Try add origin
git remote add origin https://github.com/user/repo.git
It was my failure in identifying the working directory. After I refactor my project into the new name, somehow Git Bash application move the default working directory to the upper level. I didn't notice this and all those commands are executed against the upper level of my new project directory.

Git push problems

i am new to webdeveloping and stuff, I want to push my html and css files to github but after I do git commit and git push origin master I get this error:
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
Sorry if this is a silly question, but I am new and I couldn't find the answer online. I looked into several tutorials and did not succeed in pushing my page to GitHub. I have managed to update my README.md file using this tutorial: http://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository
From the GitHub documentation, you need to configure your origin to point to the GitHub remote:
git remote add origin https://github.com/user/repo.git
# Set a new remote
git remote -v
# Verify new remote
Replace https://github.com/user/repo.git with the actual path to your remote repository on GitHub.
The issue is that you don't have the repository uploaded remotely (ie. on Github).
Follow these instructions if you want the repository pushed to GitHub: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/. You seem to have done the first 6 steps already (up to committing). Note: you require a GitHub account for this and the repository will be publicly available to read unless you pay (don't worry - people won't be able to write into the repository unless you let them).

Resources