GIT SSH Connection to server and create repository there and add files - windows

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

Related

Automate gitlab project creation and push to repository

Since I have more than 100 projects to be created in Gitlab, is there a way that creation till push to repository can be automated.
Create project->Clone the repo.->Push modified files.
This flow needs to be automated.
Please provide me reference incase of no specifics.
Projects don't have to be created in advance. You can just push to any namespace to create projects.
git remote add origin ssh://git#gitlab.example.com/mynamespace/my-newproject.git
git push -u origin --all
You'll see the server respond back with a message like this:
remote: The private project mynamespace/my-newprojct was successfully created.
If you wanted a script to create a project from scratch, you might do something like this:
#!/usr/bin/env bash
# create-project.sh
gitlab_host="gitlab.example.com" # replace with your host
project_path=$1
project_name="$(basename "${project_path}")"
mkdir "$project_name"
pushd "$project_name"
echo "# ${project_name}" > README.md
# Put any additional project file creation steps here
git init
git checkout -b main
git add .
git commit -m "initial commit"
git remote add origin "ssh://git#${gitlab_host}/${project_path}.git"
git push -u origin main
popd
Usage:
./create-project.sh mynamespace/my-newproject
This will create a directory my-newproject, setup repo files, remote, and push it to GitLab creating the project.

Git push error - failed to push some refs to <path>

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.

Igloo Software: Confirm successful transfer to local machine

I have a lot of files stored in Igloo that I am copying over to my local machine, and must confirm that everything was indeed copied over successfully without missing any files/folders. There are lots of directories and sub-directories so manually checking that takes a long time. Does anybody know how to use Git/winmerge, Igloo's version control, or another 'diff checker' solution to make sure everything was copied over successfully from Igloo to my local machine?
If you use git to version control your lgloo software, it will make things easier.
Remote git repo: setup your own remote repo, or sign up for github/bitbucket etc and hosted your remote repo there.
Local git repo: make changes for lgloo and sync with remote repo.
First time to sync with local repo to remote:
# In an empty local path
git init
# copy lgloo software in the path
git add .
git commit -m 'init commit'
git remote add origin <URL for remote repo>
git push -u origin master
After that, when you want to copy the whole lgloo software into your local machine and check if it copied successfully. You just need to execute the commands in the same local path:
git pull origin master
git log master..origin/master
If there is no output after git log master..origin/master, that means you copied the latest lgloo software successfully.

How to push in heroku?

I clone my repo down and change something and commit,
but when I want to push like the tutorial:
git push heroku master
it tell me wrong:
fatal: 'heroku' 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.
I'm sure I have log in,
so how can I push my repo correctly and deploy it?
From Git Reference (http://gitref.org/remotes/#remote):
"So that you don't have to use the full URL of a remote repository every time you want to synchronize with it, Git stores an alias or nickname for each remote repository URL you are interested in. You use the git remote command to manage this list of remote repos that you care about."
You can check if remote named "heroku" exists for your git repo using:
git remote -v
If it doesn't exist, you need to add it before you can push updates as follows:
git remote add heroku git#heroku.com:appname.git
where appname should be the name of your app.

Git server and clone

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

Resources