Getting 'Repository does not exist' when pushing from cloud9 toBitbucket - ruby-on-rails

In the book Ruby on Rails Tutorial Micheal Hartl recommends using the Cloud9 https://c9.io cloud IDE. I created a Bitbucket account, set up Git on the IDE, and installed Rails on Cloud9.
git push -u origin --all and getting error message conq: Repository does not exist.
fatal: could not read from remote repository
please make sure you have the correct access rights and the repository exist.

Log into the Bitbucket website and navigate to the dashboard. On the overview tab, you should see a link like 'john_larkin / hello_app'. Click on the link and you will see the Overview page for this repository. At the top right of the page, you will see an SSH select. The name of your repository appears to the right of that select. It should look something like:
git#bitbucket.org:john_larkin/hello-app.git
In your Cloud9 terminal session for the hello app project, issue the command:
git remote add origin <repo>
replacing <repo> with your repository name from Bitbucket.
Once you do this, you should be able to successfully push your code and updates to your repository.
SSH Key
If you are still experiencing issues, make sure you have successfully loaded your SSH key from your Cloud9 IDE into Bitbucket:
Go to https://bitbucket.org/.
Click on your avatar in the upper right hand corner of the page and select 'Manage account'.
Click on the 'SSH Keys' link under Security on the left side panel.
You should see a key listed there - click on the 'edit' link (if you don't see a key, click on the 'Add key' button to add a new key).
On your Cloud9 IDE, click on your avatar at the top of the screen and select 'Dashboard'. Click on 'Show SSH key' on the right of the screen to view your Cloud9 SSH key. This key should match what appears in the Bitbucket edit view. If it does not or you are unsure, you can always delete this key and create a new key by copying your Cloud9 key into Bitbucket.

I got problem to configure C9 and Bitbucket, but after fighting, i win. So, in the first time, for myself i just delete my repo and my app, i was only on the beginning of creation. If its not your case, im not sure, but if you click (upper left) option to show hidden file and delete the .git, that can probably help.
So, i will enumerate my step that make the connection between C9 and Bitbucket working for me.
In C9
git config --global user.name "Your name"
git config --global user.email "email#exemple.com"
git init
git add -A
git commit -m "Creation of my application"
cat ~/.ssh/id_rsa.pub (take all ssh key except email)
In Bitbucket
Add SSH key in Bitbucket Settings
Create Repository
In C9 add Bitbucket code exemple
git remote add origin git#bitbucket.org:(user info)
git remote -v (to see if its correct)
git push -u origin master
At this stage, all should be pushed to Bitbucket
After to push again your code to Bitbucket
git add -A
git commit -m "Your comment here"
git push
Hope that can help some people.

Create a remote repository, in the web site, before pushing it from your local repository.

I had this issue as well. Make sure you added something to the repository with
git add -A
and then
git add -m "Your message"
Then try to push the repository upstream.

Related

How to fix Bitbucket warning "You appear to have cloned an empty repository"?

I am using the Bitbucket tool in my project, so I created the clone URL and I tried to add my local code into the repository. I am using Terminal for the cloning process. while the process I am getting the error like this "Warning: You appear to have cloned an empty repository.".
I want to clone my project and I have to upload my codes into the repository. if anyone knows how to fix this, could you please help me.
Once you have cloned your (empty) repository, you still need to:
add files in the local folder created by the git clone command.
type
:
git add .
git commit -m "First batch of files"
git push -u origin master
Then your remote BitBucket repository won't be empty anymore.
This happens when you are cloning a freshly created repository with no commits.
As it says, it is just a warning. If it is expected that there is nothing in the repository, you can go ahead and add files and commit and push back.
to push it
git add --all
git commit -m 'your commit message'
git push origin master
If it is not supposed to be empty, contact the person/admin who gave you the link.

Can't push or commit to GitHub in Xcode 9

I created Git Hub account and clone using SSH
I went to Create Git Repositories. I chose both project folders POD and SFITNESS. Then xCode created the following:
Then I right click on SFITNESS and ADD EXISTING REMOTE which I log in to GitHub to provide the link, everything works fine.
When I went to commit, I choose the SFTNESS folder and commit and at the bottom it allows me to Push to remote which I choose the remote at step 3.
Then it will prompt me for the Username and Password and I can never get the authentication correct. The Username and password is it for Github? I can never get the authentication correct?
Now, at the commit window I have lost my SFITNESS folder, how do I commit again? Is it push now?
Need to Add SSH following this link and use SSH as authenthication.

How to clone a Gerrit Code Review repository to a local repository

I have installed Gerrit Code Review. Everything is working fine but in the documentation it is unclear how to clone a repository to local directory.
Using Gerrit admin interface I created a new project. How do I know what URL to use? Does Gerrit support https access to repositories?
Go to Gerrit Web UI
Go to the "Projects > List" menu item
Find your project (use the "Filter" field if needed)
Click on the project name
Go to the "General" tab
See the "git clone" command on the top of the page
Choose if you want to clone via "http" or "ssh"
Copy the "git clone" command clicking on the right icon
Paste/execute the "git clone" command
As it turns out this issue is related to SSH/HTTP/Anonymous HTTP Clone URL not visible in Gerrit 2.12.2
I installed in batch mode without plugins. In that case git clone is not there.

Beginner RoR Git config --global user name error

I am having trouble setting a global user name for git. When I type in git config --global user.name, I get the following error: "fatal: unable to access 'H:/.config/git/config': Invalid argument"
I have created a github account and thought I had made a repository for the project I'm working on, but I am not really sure if I did it right (or if this is related to the issue I am having). Also I get the same error, when I type in git init or git config.
Thanks for any help in advance. If possible, please be detaied as I am learning through tutorials right now. I do have git successfull installed (when I type in git -v I get a version number and ruby and rails are ok as well).
Getting Started with a new Github Account ->
1.) Create a Github Account (You probably done this)
2.) Navigate to your App's Folder (cd yourfoldername), you must be in your App's folder to configure git Properties.
$ git config --global user.name "Your Name" # Set your Git name
$ git config --global user.email youremail#gmail.com # Set your Git email
3.) Follow these Steps
$ git init # Set up Git on your project
$ git status # See tracked, untracked, and staged files
$ git add . # Add new files to Git
$ git commit -am "Initial commit" # Save your project files to Git
4.) Your App is now under Version Controll, now you must Generate your SSH Key.
-> Generating SSH Keys
If you are on Windows you can just download the Github Application, it will save you a lot of this Manual Setup. But setting up SSH Key's is not so difficult. Just follow the Guide.
5.) Then, you create a New Repository on Github, and it tells you on Page to enter this 2 lines. Youre Done :)
$ git remote add origin git#github.com/yourusername/yourreponame.git # Set up git to push to your Github repository
$ git push -u origin master # Push your code to Github (sets the upstream the first time)
Hope this Helps.
P.S.: I started learning Rails a few weeks ago -> Check this class on skillshare out -> One Month Rails: Learn to Code !!
Are you also providing your user name as an argument? It should be git config --global user.name "User Name". Just checking since you didn't mention that in your question.

How to upload a project to GitHub

After checking How can I upload my project's Git repository to GitHub?, I still have no idea how to get a project uploaded to my GitHub repository.
I created a repository and want to upload my project to it.
I've looked on the repository page for an upload button of some kind, but I haven't seen anything of the sort.
I've looked at the links provided so far, but I'm still getting nowhere. They mention command line; is that Windows command line or Git Bash? Because I can't get either to do anything.
I also tried using the Git GUI, but when I select the folder I want it says that it's not a Git repository...does it need to be zipped up? I tried adding the .gitconfig file in the folder, but it doesn't make a difference.
GitHub released a native Windows client which makes all the below steps redundant.
You can also use Sourcetree to get both Git and Mercurial setup on Windows.
Here is how you would do it in Windows:
If you don't have Git installed, see this article on how to set it up.
Open up a Windows command prompt.
Change into the directory where your source code is located in the command prompt.
First, create a new repository in this directory git init. This will say "Initialized empty git repository in ....git" (... is the path).
Now you need to tell Git about your files by adding them to your repository. Do this with git add filename. If you want to add all your files, you can do git add .
Now that you have added your files and made your changes, you need to commit your changes so Git can track them. Type git commit -m "adding files". -m lets you add the commit message in line.
So far, the above steps is what you would do even if you were not using GitHub. They are the normal steps to start a Git repository. Remember that Git is distributed (decentralized), meaning you don't need to have a "central server" (or even a network connection), to use Git.
Now you want to push the changes to your Git repository hosted with GitHub. You do this by telling Git to add a remote location, and you do that with this command:
git remote add origin https://github.com/yourusername/your-repo-name.git
*Note: your-repo-name should be created in GitHub before you do a git remote add origin ...
Once you have done that, Git now knows about your remote repository. You can then tell it to push (which is "upload") your committed files:
git push -u origin master
Follow these steps to upload a project to GitHub:
git init
git add .
git commit -m "Add all my files"
git remote add origin https://github.com/yourusername/your-repo-name.git
Upload of project from scratch require git pull origin master.
git pull origin master
git push origin master
git push --force origin master
if you have problems uploading!
Here I explain how I did it on Windows.
Make sure to install Git and GitHub.
After installation is complete, open Git Bash.
So a window like below is going to pop up:
Go ahead and type cd ~ to make sure you are in the home directory. You can check the address that you are in it by typing pwd;
Now you need to create a GitHub account. After creating a GitHub account, go ahead and sign in.
After you signed in, on the top right click on the + and choose “New Repository”
Then in the opened window, type the name that you wish to have for the repository in the “Repository name” box. Add “Description (optional)” if you like, and mark “Initialize this repository with a README”. Then click on “Create repository”.
Now go to your C drive; create a new folder and name it “git”. Now go to the “Git Bash” window; change the directory to c drive by typing cd ~; cd /c.
If you type ls there it would show you the folders there. Make sure it shows the Git folder there:
Now go back to the browser; go to your GitHub page, click on the repository that you made, click on “Clone or download”, and copy the address that shows there (by choosing copy to clipboard).
Now going back to “Git Bash”. Use the command cd git to go to the git folder; now write the following commands to connect to your GitHub (enter the username and password of your GitHub when it asks you):
git config --global user.name "Your Name"
And then: git config --global user.email youremail#domain.com.
Next type: git clone (URL), instead of the (URL), type the address of the GitHub repository that you copied from your GitHub page; (e.g., git clone https://github.com/isalirezag/Test.git).
Now if you do ls command you will see your repository there. If you also open the Git folder that you have in your window you will see that your repository is added as a folder.
Now use the cd command to go to the repository: cd Test
Go ahead and copy and paste any files that you want to put in this repository in that folder.
In order to transfer the files to your repository you need to do following now:
Type git
add filename (filename is the file name that you want to upload) or you can type the command below if you want to add all the files in the folder:
git add .
Then type: git commit -m "adding files". And then: git push -u origin master .
And then you should be all set. If you refresh your GitHub account, the files should be there :)
Follow these steps to upload your project to GitHub:
git init
git add .
git commit -m "Add all my files"
git remote add origin https://github.com/yourusername/your-repo-name.git
Upload of the project from scratch requires git pull origin master.
git pull origin master
git push origin master
If any problem occurs in pushing, use git push --force origin master.
Follow these two steps:
Create the repository online using the link: https://github.com/new
Then link your local repo to the remote repo using the command: git add remote origin https://github.com/userName/repo.git
Here the repo.git will be your newly created remote repo.
This will work like a charm. No need to worry about the SSH or HTTPS ways. I first faced the same issue and spent hours for solution.
But this worked for me.
Easy-to-follow steps: git pull origin master or main will give a fatal error:
Couldn't find remote ref main
So below steps will work just fine.
git init
git add .
git commit -m "initial commit"
git remote add origin https://github.com/yourusername/your-repo-name.git
git branch -M main
git push -u origin main
This worked for me;
1- git init
2- git add .
3- git commit -m "Add all my files"
4- git remote add origin https://github.com/USER_NAME/FOLDER_NAME
5- git pull origin master --allow-unrelated-histories
6- git push origin master
Create a new repository on GitHub. To avoid errors, do not initialize
the new repository with README, license, or gitignore files. You can
add these files after your project has been pushed to GitHub. Open
Terminal (for Mac users) or the command prompt (for Windows and Linux
users).
Change the current working directory to your local project.
Initialize the local directory as a Git repository.
git init
#Add the files in your new local repository. This stages them for the first commit.
git add
# Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'. Commit the files that you've staged in your local repository.
git commit -m 'First commit'
#Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.
At the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL. At the top of your GitHub repository's Quick Setup
page, click to copy the remote repository URL.
In the Command prompt, add the URL for the remote repository where your local repository will be pushed.
$ git remote add origin remote repository URL
# Sets the new remote git remote -v
# Verifies the new remote URL Note: GitHub for Windows users should use the command git remote set-url origin instead of git remote add origin here. Push the changes in your local repository to GitHub.
$ git push origin master
# Pushes the changes in your local repository up to the remote repository you specified as the origin.
Source attribution: Adding an existing project to GitHub using the command line
I assume you are on a Windows system like me and have Git installed. You can either run these commands by simple command prompt in the project directory or you can also use Git Bash.
Step 1:
Create a repository in Git manually. Give it whatever name you seem fit.
Step 2:
Come to your local project directory. If you want to publish your code to this new repository you just created, make sure that in the projects root directory there is no folder name .git. If there is, delete it.
Run command git init.
Step 3:
Run command
git add .
Step 4:
Run command
git commit -m YourCommitName
Step 5:
Run command
git remote add YourRepositoryName https://github.com/YourUserName/YourRepositoryName.git
Step 6:
Run Command
git push --set-upstream YourRepositoryName master --force
Please note that I am using the latest version of Git at the time of writing. Also note that I did not specify any particular branch to push the code into so it went to master. In step 6 the Git will ask you to authorize the command by asking you to enter username and password in a popup window.
Open Git Bash.
Change the current working directory to your local project.
Initialize the local directory as a Git repository: $ git init
Add the files in your new local repository. This stages them for the first commit: $ git add .
Commit the files that you've staged in your local repository: $ git commit -m "First commit"
At the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL.
In the Command prompt, add the URL for the remote repository where your local repository will be pushed : $ git remote add origin remote repository URL
Push the changes in your local repository to GitHub: $ git push origin master
First you have to create an account on GitHub
Then create a new project - name that project as you want and then your project URL is shown
Now copy the URL
Then open a Command Prompt and go to the directory or folder which you want to upload using cmd
Then type the following commands
git init
git add .
git commit -m "initial commit"
git remote add origin PASTE URL
git push -u origin master
Now check your GitHub account. The repository is successfully uploaded.
For complete guidance, you can watch this video.
It took me like 1-2 hours to realize that I'm supposed to create the repository at GitHub before trying to push my local files to GitHub (or whatever, Git service you're using).
After trying to push, errors were like:
remote: Repository not found.
fatal: repository 'https://github.com/username/project.git/' not found
I feel like an idiot, but I really would like to emphasize this for beginners like me. I just thought that my repository will be created automatically during the first push. I was so wrong.
You can see your remotes with this command:
git remote -v
Steps to upload project to Git:
Step 1 - open cmd and change the current working directory to your project location.
Step 2 - Initialize your project directory as a Git repository.
git init
Step 3 - Add files in your local repository.
add .
Step 4 - Commit the files that you've staged in your local repository.
git commit -m "First commit"
Step 5 - Copy the remote repository URL.
Step 6 - Add the remote repository URL as origin in your local location.
git add origin copied_remote_repository_url
Step 7 - Confirm your origin is updated or not.
git remote show origin
Step 8 - Push the changed to your GitHub repository
git push origin master.
I think the easiest thing for you to do would be to install the Git plugin for Eclipse. It works more or less the same as the Eclipse CVS and SVN plugins.
Make sure that Git is installed on your system. I'm explaining the process using windows OS [Although it shouldn't be OS dependent job]
Here is how I did:
Open the cmd (you can do with git bash as well if you've installed git bash).
Go to your project directory (where your project is located, it's essentially changing to directory either usiing cd path or through manual folder navigation).
Now type git init. This will initialize an empty repository if it is first time and Enter.
For example: git init
Now type git add <filename>(if specific file) or git add <filename1> <filename2> <filenameN> (if specific but more than one files) or git add . (if you want to add all files) and enter.
Now type git commit -m "commit message goes here" and enter.
(in case if you need to check the status you can do by typing git status) and enter.
Now type git remote add origin git_repository_url
(check git remote -v go check remote repository) and Enter.
Now it's turn to push it to the remote repository [essentially taking all the changes from local git to cloud(github) ...git push origin master and enter
(if you get error you push it forcefully by typing ...git push -f origin master and enter.
NOTE : master is the name of your master branch. If you've multiple branches, make sure that you select the name of the branch accordingly.
Now you're done with adding it to your remote repository from local computer. Refresh it and it will be there in your created repository's selected branch.
Probably the most useful thing you could do is to peruse the online book Pro Git. It's really a pretty decent read and gives you the conceptual context with which to execute things properly.
Follow the instructions from RishiKesh Pathak. You can even short the push command by inserting this command line one time only:
git config --global push.default simple
So next time instead of using git push origin master you just need:
git push
See details here.
Download Sourcetree.
It is available for Windows 7 (and later) and Mac, and it is highly recommended to upload files on GitHub via the interactive UI.
The best way to use Git is to actually start Gitting. Try out this website which makes you go step by step on what are the essential ways for performing functions on command line for pushing a project on GitHub.
This is called try.github.io or you could also take up a course on Codecademy.
I did as follows;
git init
git add .
git commit -m "Your_message"
git remote add origin #your_git_repository
git push -u origin master
Of course you have to install Git.
We need Git Bash
In the Git Bash Command Section:
ls
It will show your default location.
CD "C:\Users\user\Desktop\HTML"
We need to assign the project path.
git init
It will initialize the empty Git repository in C:\Users\user\Desktop\HTML
ls
It will list all file names.
git remote add origin https://github.com/repository/test.git
It is your https://github.com/repository/test.git is your repository path
git remote -v
To check whether we have fetch or push permission or not
git add .
If you use . then it means whatever we have in the particular folder publish all.
git commit -m "First time"
git push -u origin master
Upload a project from Visual Studio Code to GitHub
To upload your project in GitHub using Visual Studio Code, follow the following steps.
Open the Visual Studio Code. if you don't have the VSCode download: Download Visual Studio Code
In VSCode go to File-->Open Folder..
Go to Terminal-->New Terminal
Execute the following commands one by one after one another in order
git init
git add .
git commit -m "First Commit"
git remote add origin https://github.com/yourusername/your-repo-name.git
git push origin master
Note: in the above command git remote add origin https://github.com/yourusername/your-repo-name.git please change the bold sections with your GitHub account name and your repository name.
You need an SSH connection and GitHub init into your project. I will explain under Linux machine.
Let's start with some easy stuff: navigate into your project in the terminal, and use:
git init
git add .
git commit
Now let's add SSH into your machine:
use
ssh-keygen -t rsa -C "your_email#example.com"
Copy the public key, and then add it to your GitHub repository:
Deploy keys -> add one
Back to your machine project, now launch:
git push origin master
if there is an error, configure your .github/config file by
nano .github/config
And change the URL to the SSH one by:
url = git#github.com:username/repo....
And that's it.
Try using Git Bash to push your code/make changes instead of uploading files directly on GitHub (it is less prone to errors and is quite comfortable at times - takes less time as well!). For doing so, you may follow the below given steps:
Download and install the latest version of Git Bash from here.
Right-click on any desired location on your system.
Click “Git Bash Here”.
git config --global user.name “your name”
git config --global user.email “your email”
Go back to your GitHub account – open your project – click on “clone” – copy HTTPS link.
git clone PASTE HTTPS LINK.
A clone of your GitHub project will be created on your computer location.
Open the folder and paste your content.
Make sure content is not empty.
Right-click inside the cloned folder where you have pasted your content.
Click “Git Bash Here” again.
You will find (master) appearing after your location address.
git add .
Try git status to check if all your changes are marked in green.
git commit --m “Some message”
git push origin master
You just need to know few command im cmd to push or pull any directory to/from github.
Command to push/upload any project or code to the git hub.
First reach to the working directory or project directory which you need to upload.
to check the correct working directory
ls
to initialize the git in the directory
git init
to the check that git init worked or not
ls -a //this command shows hidden files
Using above command you will find file added in you directory.
./ ../ .git/
the above is not a command you can skip it.
Now add the files of working directory to commit
git add .
then use commit command and name that commit for reference
git commit -m "Commit Name"
Before final step you need to go to the github website and create a new repository and copy the url of the repository
git remote add main https://github.com/username/repositoryName.git
now command to upload the directory
git push -u main
Note: the name "main" is the name that can be change as per user
For uploading a new project into Git (first you need to have the local code base of the project and the Git repository where you will be uploading project. In Git, you need to have your credentials).
List item
Open Git Bash
Go to the directory where you have the code base (project location)
cd to project location
cd ////**
Then here you need to execute Git commands.
git init
Press Enter then you will see something like this below.
The initialized empty Git repository in ://****/***/.git/, so git init will initialize the empty Git repository at local
git add .
Press Enter
The above command will add all the directories, subdirectories, files, etc.
You will see something like this:
warning: LF will be replaced by CRLF in **************.
The file will have its original line endings in your working directory.
git commit -m "first commit"
Press Enter. -m provided option for adding comment.
It will commit the code to the stage environment.
You will see some thing like this:
[master (root-commit) 34a28f6] adding ********
warning: LF will be replaced by CRLF in c*******.
The file will have its original line endings in your working directory.
27 files changed, 3724 insertions(+)
create mode 100644 *****
create mode 100644 *****
create mode 100644 *****
git remote add origin
http://username#git:repopath.git
Press Enter. This will add to the repository.
git push -u origin master
Press Enter.
This will upload all from local to repository in this step you need to enter password for the repository where you will be uploading the code.
You will see some thing like this below:
Counting objects: 33, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (32/32), done.
Writing objects: 100% (33/33), 20.10 KiB | 0 bytes/s, done.
Total 33 (delta 14), reused 0 (delta 0)
To http://username#git:repolocation.git \
[new branch] master -> master
Branch master set up to track remote branch master from origin.

Resources