1

after searching quite a lot without findind nothing about it I'm here to ask you if there is a way to implement Git in a pure Javascript web application. I already know about Git.js but it implements just some basic things and I also wanted to build my own library to learn more in depth about Git.

What I'm not looking for is an API or a lib that could help me.

What I'm looking for is something like:

var command = {{git commit -m "Hello world"}} // Also pure git implementation
gitExecute(command);

I'm still a junior developer and maybe this could be impossible...thanks for the reply :)

2 Answers 2

2

What you are asking for may be difficult to do in a browser (because you will need access to the file system to run git commands). What you may need to do is create a NodeJS server which exposes REST endpoints which can be accessed by code in the browser which provides the GUI. The NodeJS server code can run commands as needed and respond to the REST HTTP requests which can be then used by your code in the browser to show/update the GUI.

The disadvantage with this method is that you will need to run your NodeJS server on the computer which has the repository and will not work if the repo is not local to the server.

Another alternative is to use the REST APIs exposed by popular GIT providers like GitHub.

EDIT:

Come to think of it, your usecase may be a good fit for an Electron App. That will allow you to build a desktop app (with access to the filesystem and privileges to execute commands) using Javascript.

Sign up to request clarification or add additional context in comments.

Comments

0

For this purpose, NodeJS is mandatory.

You could install git on your server machine, and thene execute your cmds through nodejs' child processes (DOCs)

1 Comment

hey but how to talk to the remote github repos by making a login system for github so that we can push our code to github like gitCommand -> browser -> server -> githubRepo

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.