Clone failing against my new Windows 7 Git server using copssh, msysgit - windows

I have created a git server on my Windows 7 box following Tim Davis' tutorial
Got everything working up to the part of actually trying to clone the repository.
I have a repo located on my server at:
C:\SSH\home\repos\testapp.git that I have initialized using git --bare init as per the tutorial, and try to clone it using GiT GUI via:
ssh://repos#myurl/SSH/home/repos/testapp.git
but get an error dialog popping up describing "Clone failed. Cannot determine HEAD. See console output for details." and "Couldn't find remote ref HEAD".
I tried making a new repo out of an existing project folder (hoping that this 'ref' would magically correct itself) but the same thing message occurs.
Is there something more after a '--bare' or an 'init' that needs to be done to set the head reference?

Most probably it's failing because it is an empty repository. You can try to add an initial ( dummy commit if needed ) to the repository and try the cloning again. Steps below if you don't know to do this.
Can you do this:
cd /home/repos
mkdir testapp.wd
cd testapp.wd
git clone ../testapp.git .
<now add some file>
touch README
git add README
git commit -m "Adding a initial commit"
git push origin master
cd ..
rm -rf testapp.wd
Now see if you can do the clone that you were trying.

If remote repository is empty, it will happen. Try to commit something.

Related

git push to create new GitHub repo not working

I am trying to create a script that prompts for a name to give to a new GitHub repo, and then create the GitHub repo by pushing to the remote URL which the new GitHub repo will have. When I use the script I get these errors:
remote: Repository not found. fatal: repository 'https://github.com/JT-style/great.git/' not found
read -p"Enter the name of remote repository: " name
mkdir ~/rep/$name
cd ~/rep/$name
echo "#$name" >> README.md
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/JT-style/$name.git
git push -u origin main
echo "Done"
Why doesn't this work? What can I do to achieve my goal?
p.s. This is my first script.
You can't push to a repository to github if it doesn't already exist. Usually, you'd create one through a web browser by going on their site, but they released a cli called gh, which allows creating repositories (you have to authenticate somehow before though).

How can i upload a Spring Java project to GitHub so i can show my work?

I've tried through various ways, directly uploading the files wont work. I've tried through bash and nothing.
Do you have git installed?
# Create a new repository on the command line
#Go to Project Directory on your Computer, Open git Bash here
# run the following 1 by 1
git init
git add .
git commit -m "Comment here"
git remote add origin https://github.com/YourRepoPrefixHere
git push -u origin master
If you have a git profile and a repository you can take these simple steps to get it online:
Open a terminal and go inside the folder of the project you want to push to your git repository
Check if you are on the right git branch: git checkout
git add .
git commit -m "your messagge to commit"
git push origin -u "yourbranchName
If you have never set up your origin branch, you should add it before using it:
git remote add origin "github link"
To see if everything went well you can do a simple: git status.
I hope it will be useful to you my friend!

something went wrong when pushing to github with webstorm

As is shown in the image,I'm not sure if the failure is caused by some missing property while setting up webstorm .
The issue is not resolved after a lot of efforts.As a learner,I don't know what to do now.
Meanwhile,something seems wrong as shown in git bash.I've no idea whether the two are directly related.
If you have ever faced these difficulties,could you please give me some idea? Even if it's only a web address.
What I want to do is only pushing my code. Anyone who pushed successfully in any other way will be welcomed to share your method.
If I'm being honest I'm not sure that I completely understand your question, but I will supply some information that will hopefully lead you down the right track.
First in the bash shell, cd (change directory) into your project directory like this:
$ cd /c/foo/bar/yourprojectfolder
In your project top most directory, do you have a .git folder? You may have to show hidden folders in windows to see this directory. If not, you need to initialize a repository with the init command.
$ git init
Initialized empty Git repository in C:/foo/bar/yourprojectfolder/.git/
After running this command, you should see a .git folder inside of the directory you changed to (used cd to get to) earlier.
Next, in order to push, you first need a remote repository to push to. Based on your first picture, I believe that you have successfully created a repository on GitHub. If not however, just log into GitHub and click the 'New Repository' button:
Once a repo has been created, you need to add it as a remote to your local git (in git bash). To do this you need a url (either SSH or HTTPS) to your repo. You can find this url inside of your repository in online GitHub. If you are not certain you have set up SSH, it's best to use the HTTPS url. It should look something like this, but the url itself will be different and specific to your repository:
Copy that url to your clipboard, and then back in git bash run:
$ git remote add origin <PASTE YOUR URL HERE>
You need to make an initial commit of your code to have something to push:
$ git add .
$ git commit -m "Initial commit"
Finally, with the origin repo set up and a commit made, you should be able to push to your origin repo
$ git push -u origin master
You should now be able to view your code on GitHub.

How to publish Github repository

I need to publish a Github repository from a directory on my computer.
I added, committed, and pushed the origin master of the files I wanted to publish from the root directory of my project. By that, I mean I clicked the "create a new repository" button and typed all the git commands in my terminal while in the project directory I want to publish as my repository. For a list of the commands I used, see the below section labeled "Code."
I saw no errors during the terminal commands. When I finished, all I saw in my repository was the README.md file and nothing else.
I tried to check at my terminal to see if my login name matched the Github username of the target repository. But I didn't see any commands for checking the login name at the terminal.
OS/config: Using OS X 10.10.5 (Yosemite) on MacBook Air
Code
I tried this...
git init
git add README.md # This is the problem. (See my answer below.) Should be "git add ."
git commit -m "first commit"
git remote add origin https://github.com/"username"/"repository".git
git push -u origin master
Heres a basic push to GitHub, What kind of errors are you getting?
create a new repository on the command line
git init
git add . //This will add everything in the directory
git commit -m "first commit"
git remote add origin https://github.com/"username"/"repository".git
git push -u origin master
…or push an existing repository from the command line
git remote add origin https://github.com/"username"/"repository".git
git push -u origin master
Here is what solved the problem for me...
That second git command line should be git add . not git add README.md. The . adds all the files in the directory, as mentioned by the accepted answer.
Code
Solution
git init
git add . # This was the key line to change from what was tried in the question.
git commit -m "first commit"
git remote add origin https://github.com/username/repository
git push -u origin master

Migrating forked project from Heroku to Github

Some time ago I found some code in one Github repo. I downloaded it (did not fork it), started upgrading it and when I was happy with the result, I used Heroku as a host. So now the code lives on my computer and Heroku. How could I push it to my Github account, but also give the original author of the project some credit for it (showing on my Github that I actually forked it)?
Okay, so I actually figured it out already!
First, create a new repository on github, let's name it github-project.
git clone git#heroku.com:<heroku-project>.git
cd <heroku-project>
git remote rm origin
git remote add github https://github.com/<github-username>/<github-project>
git pull github master
Now you'll probably see some conflicts. If you want to preserve all your changes, just add them all.
git add .
git commit -m "some message"
git push github master
This is quite simple:
Create an empty repository on GitHub, let's call it github-project
Clone from Heroku, let's call it heroku-project
Add a remote for github
Push to GitHub
The commands to perform these steps:
git clone git#heroku.com:heroku-project.git
cd heroku-project
git remote add github https://github.com/github-username/github-project
git push -u github master
That's it!
Note: if you already created the GitHub project with a README file in it, then it is NOT empty anymore, and the last push will be refused. In that case you can force the push, effectively overwriting the project on GitHub, by using the --force flag, for example:
git push -u github master --force

Resources