-2

I am learning Git I have a website hosted on godaddy. Using 'Git Bash' tool, I initialized it into a git repo by using git init.

THIS IS WHAT I DID (in detail)

Using Git Bash, I SSH into the remote godaddy servers as below

SSH my-user-name@177.62.28.96, and then ran the following git commands to initialize the existing files as a git repo. git init, git add * git commit...

Now this is named as masterbranch of the repo.

THIS IS WHAT I WANT TO DO

I want to pull this git repo to a local folder, make changes and then git push it back.

THIS QUESTION IS OPENED AGAIN (here is why) It is because answer by @dendress suggests that one should initialize the remote repo as bare. Problem with this answer is that though it pushes successfully, but the changes are not reflected on the remote files.

TO SOLVE THIS IS WHAT I DID Docs suggest that in a bare repo there is no working tree. so changes can't be reflected. so what I did was

  1. I removed the .git/ folder,
  2. re-initialized the directory with git init,
  3. cloned it in my local machine using git clone my-user-name@177.62.28.96 and made changes
  4. on server, I changed the repo to bare by git config --bool core.config true
  5. from my local machine, I ran git push origin master
  6. here is the output of it

Pareek@ram MINGW64 /c/wamp/www/git/sarv/sarv (master) $ git push origin master pareekbhagu@177.62.28.96's password: Counting objects: 5, done. Delta compression using up to 4 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 442 bytes | 0 bytes/s, done. Total 5 (delta 4), reused 0 (delta 0) To pareekbhagu@166.62.28.96: 8d4041d..7906308 master -> master

I think this means the push is successful, but **

How do I make the changes reflect on my remote repo

**

Ramesh Pareek
  • 1,601
  • 3
  • 30
  • 55
  • I am sorry I'm quite new to git, do you mean running `git remote add master http://my-domain.com` ? – Ramesh Pareek May 24 '16 at 11:29
  • You should not have done this. You've turned your entire home directory into a Git repository. You are meant to choose a specific sub-folder and run the `git init`/`git add`/`git commands` from within it. – user229044 May 24 '16 at 15:32

2 Answers2

2

You have to clone the repository to your local machine first. This can be done with the git clone command like

git clone my-user-name@177.62.28.96:path/to/git/repo

After that you can do your edits and then push them back to the server with

git push origin

Note:

  • You should initialize your repository on the server as a bare one (git init --bare) since you want to push to it.
  • If you want to do changes on another branch than master run git checkout -u branch-name after cloning the repository.
hdlgi42
  • 74
  • 5
  • It says....Cloning into '177.62.28.96'... Does that mean it is cloning the local files to the server... Should I go ahead? – Ramesh Pareek May 24 '16 at 11:39
  • Are you sure you got the path to the repository right? For my example it should print: `Cloning into 'repo'` since repo is the folder containing the git repository in my example. Please check if you specified the correct path to your git repository or paste the command you ran here. – hdlgi42 May 24 '16 at 11:48
  • I have a `testgit` folder. `177.62.28.96:/testgit`.. in this folder I ran the command `git init`. Now it created a folder `.git` in this (`177.62.28.96:/testgit/.git`). But the message I get is `fatal: '/testgit' does not appear to be a git repository fatal: Could not read from remote repository. ` – Ramesh Pareek May 24 '16 at 12:01
  • Please try initializing the repository on the server as a bare one (`git init --bare`) and then try the rest like before (add, commit, clone). If you want to push to a repository you should always make it a bare one. – hdlgi42 May 24 '16 at 12:11
  • it works now. thanks. A small edit: instead of `git clone my-user-name@177.62.28.96:/path/to/git/repo` please edit it to `git clone my-user-name@177.62.28.96:path/to/git/repo`.. the syntax given by you is 'scp-style-syntax' which did not work... http://stackoverflow.com/questions/7318918/fatal-does-not-appear-to-be-a-git-repository#answer-7319177 – Ramesh Pareek May 24 '16 at 12:30
  • You're welcome. I just edited my answer according to your last comment. Thanks for the suggested improvement. – hdlgi42 May 24 '16 at 12:42
  • I had to open the question again, please see the updated question. – Ramesh Pareek May 25 '16 at 12:40
-1

Use the following commands: git init . git branch -m master main OR git checkout -b main git remote add origin https://139.144.16.184/gitlab-instance-ce4e845e/web.git git remote -v git pull origin main git status git add . git commit -m "My first commit" git push -u origin main