I have create my git server with this link link
git clone working in server but when i clone my project on local machine
i have a problem
"warning: remote HEAD refers to nonexistent ref, unable to checkout."
i used for clone "git clone http://domain.com/project.git"
i used virtual machine(domain.com =192.168.1.196) for git server and windows for local machine.
Thanks
On the server run the following command in a new folder to initialize a new bare git repo...
git init --bare
On your local machine go to an existing folder of create a new one and run.
git init
Copy a file into this folder and execute.
git commit -am "New repository with a new file"
Then add your server as a remote.
git remote add myserver http://domain.com/project.git
Next step is to push to your server.
git push -u myserver master
Related
I am trying to upload my code onto a repository I created on github but I get an error.
Assuming the URL of the repository is https://github.com/a, how do I go about uploading my code to my remote repository?
I tried the following commands on git bash after navigating INSIDE the folder I want to upload -
git init
(output - Reinitializing existing Git repository in C://(path)/.git/
git add.
(blank output)
git commit -m "Initial commit"
(output- On branch main. nothing to commit, working tree clean)
git remote add origin https://github.com/(path).git
(output - error: remote origin already exists)
git push origin master
(output - error:src refspec master does not match any
error failed to push some refs to https://github.com/(path).git)
Why is this happening and what could I do to push my code to my remote git repo? (I want to learn how to use git via cmd)
Thanks for reading my query!
note that you already have an remote repository configured as origin you must remove this configuration or rename then add the correctly repo.
the git command to remove remotes repositories by name is git remote remove ${repo_name}, in your case:
git remote remove origin
the git command to rename remotes repositories is:
git remote rename ${old_repo_name} ${new_repo_name}
then you can add an new remote with the name origin
git remote add origin https://github.com/(path).git
you can assume that the git command git remote add origin https://github.com/(path).git says to git configure an new remote repository into the current local repository, this remote config will "point" to the <URL> and the "alias" of this <URL> will be "origin" (or the name you specify between add and <URL>).
in this case <URL>=https://github.com/(path).git
With this you can have various remotes and specify then when you execute git push ${repo_name}
You can set an "default" upstream for git pull/status with git push -u ${repo_name}
You wrote:
git commit -m "Initial commit"
(output- On branch main. nothing to commit, working tree clean)
git push origin master
(output - error:src refspec master does not match any
Your init created a branch called main but you tried to push master, which doesn't exist. Try pushing main instead.
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!
I am running a Git Windows server. I am trying to access files locally on a Windows machine. I successfully cloned the bare repo from remote to local, but when I try to push a locally created committ, the new files do not show up on the remote server. There is no error message.
I created a bare repo on a remote server:
/path/demo.git
I cloned successfully locally with this command:
git clone ssh://username#IP:/path/demo.git
Please tell me how to push commits from the local repository to the remote repository.
When you run git clone you automatically get origin as a remote referencing the path to the repository you cloned.
You can ensure that you push implicitly to the same remote branch through configuration:
git config --global push.default current
Then create some commits and run git push.
I need help with git.
I have a server, username and parol. I connect with ssh succesfully but i cannot add files. When i want add files (from my local pc) with bash using git add it returing cannot find file path or path doesnot exist. I think it's searching files or directory in the server.
Thanks.
With Git you don't create a repository directly on a server. Instead, you
create a repository locally (git init),
add files to it, which generally comprises two steps:
stage files (git add)
commit the staged files into the local repository (git commit)
assign a remote server's repository to it (git remote add)
Note 1: I assume you have created a remote repository somehow - please refer to your server instructions.
Note 2: You create an empty repository on the server.
upload your local repository to the remote one (git push)
Sample script:
$ cd your_local_project_dir/ # Get into your your project directory
$ git init # Initialize a local repository
$ git add --all # Stage all files from your local project
# directory for commit (note this is not
# adding to the repository yet, it's just
# "prepare them to add into the repo")
$ git commit -m "Initial commit" # Add the staged files to the local repository
$ git remote add origin https://server.com/user/project_name.git
# Link the local repository to a remote one
$ git push -u origin master # Upload you local repository data to the
# remote one
So I have a git repo set up on a linux machine and I typed
git remote add test git#*****.com:/opt/git/project.git
and then I did
git init
git add *
git commit -m 'Blah blah'
When I go to do
git push remotename
I get fatal:Could not read from remote repository.
I know it is a problem on my side, because my friend can on his arch linux machine. I have private ssh keys in a different folder then my git bash and then I have public keys in the git user home folder all set up. I don't know if I need to set up SSH keys somehow with git bash or something.
You need to add the upstream repo as a remote
git remote add remotename git#*****.com:/opt/git/project.git
And now do a push
git push remotename
PS : The step where you ran git add git#*****.com:/opt/git/project.git was meaningless, and should have thrown you an error ideally.