jcubic / git

GIT Web Terminal
https://git-terminal.js.org/
MIT License
89 stars 47 forks source link

git clone is not working #15

Closed xu4wang closed 1 year ago

xu4wang commented 2 years ago

I just did a quick test, but was not able to clone... is it something wrong with CORS?

anonymous@gitwebterm:/$ mkdir test
anonymous@gitwebterm:/$ cd test
anonymous@gitwebterm:/test$ ls
anonymous@gitwebterm:/test$ git clone https://github.com/xu4wang/markgraph.git
Cloning into '/test/markgraph'...

From the ocnsole log,

sw.js:97          Uncaught (in promise) TypeError: Failed to fetch
    at sw.js:97:17
    at new Promise (<anonymous>)
    at sw.js:32:16

The error is related to fetch.

jcubic commented 2 years ago

It works but you can't use ".git" in the URL at the end. This is how isomorphic-git works, at least the version I'm using. I probably should handle that case and strip the ".git" suffix.

xu4wang commented 2 years ago

OK. thanks @jcubic for quick response.

Looks like I got some issue accessing rawgit website. will do some adjustment and try again.

xu4wang commented 2 years ago

Finally, it's working on my local machine now.

However, some of the git command is not same as I used to use.

For example, I remove one file, and git add ., I am expecting I can further git commit -mblablah to commit the deletion. But git cannot add the changes. It knows I deleted one file, but refuse to add it.

anonymous@gitwebterm:/markgraph [main]$ git log
anonymous@gitwebterm:/markgraph [main]$ git status
On branch main
nothing to commit, working directory clean
anonymous@gitwebterm:/markgraph [main]$ ls
database             doc                  library              src                  test                 README.cn.md
README.md            index.js             package-lock.json    package.json
anonymous@gitwebterm:/markgraph [main]$ rm README.cn.md
anonymous@gitwebterm:/markgraph [main]$ git status
On branch main
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in the working directory)
        deleted:    README.cn.md
anonymous@gitwebterm:/markgraph [main]$ git add .
Could not read file "README.cn.md".
anonymous@gitwebterm:/markgraph [main]$ git status
On branch main
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in the working directory)
        deleted:    README.cn.md
anonymous@gitwebterm:/markgraph [main]$ 
jcubic commented 2 years ago

A lot of things are not implemented and I don't know if I will find time to add them. The project also uses an older version of isomorphic-git the library.

But you should be able to delete the file if you use git rm README.cn.md.

xu4wang commented 2 years ago

Yes. I managed to delete it and am trying to push my commit to remote repo.

anonymous@gitwebterm:/markgraph [main]$ git rm README.cn.md
anonymous@gitwebterm:/markgraph [main]$ git status
On branch main
Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        deleted:    README.cn.md
anonymous@gitwebterm:/markgraph [main]$ git commit -m"delete readme cn"
You need to use git login first
anonymous@gitwebterm:/markgraph [main]$ git login
This will not authenticate to test if login/password are correct,
only save credentials in localStorage (expect password) and use them when push/clone/commit
username: myemail@gmail.com
password: ****
fullname: Austin Wang
email: myemail@gmail.com
myemail@gmail.com@gitwebterm:/markgraph [main]$ git commit -m"delete readme cn"
Aborting commit due to empty commit message.
myemail@gmail.com@gitwebterm:/markgraph [main]$ git commit -m "delete readme cn"
[master ca05c5e] delete readme cn
 1 file, 12 deletions(-)
 delete mode 100644 README.cn.md
myemail@gmail.com@gitwebterm:/markgraph [main]$ git status
On branch main
myemail@gmail.com@gitwebterm:/markgraph [main]$ git log
myemail@gmail.com@gitwebterm:/markgraph [main]$ git push
To https://github.com/myemail/markgraph
   111ab44..ca05c5e main -> main
myemail@gmail.com@gitwebterm:/markgraph [main]$ 

It looks good. Except when I exam the remote server in GitHub, the repo was not updated..

Seems the push was failed without any error notice.

xu4wang commented 2 years ago

Figure out the reason

                        try {
                            await git_wrapper.push({
                                dir,
                                corsProxy: 'https://jcubic.pl/proxy.php?',
                                ref: branch,
                                //authUsername: credentials.username,
                                //authPassword: credentials.password,
                                emitter
                            });
                        } catch(e) {
                            console.log(e);
                        }

The exception e was logged actually. We may need to support using an access token when pushing to github.

jcubic commented 2 years ago

An access token is supported, I use 2FA and this is the only way to push changes. You need to put a token as a password If I remember correctly.

xu4wang commented 2 years ago

An access token is supported, I use 2FA and this is the only way to push changes. You need to put a token as a password If I remember correctly.

Yes. True. I use the token for password, the push was successful!