简体   繁体   中英

Using Git from client-side javascript

I wonder if there is a js library of some sort dedicated to working with Git. Particulary I'm interested in the following js-git interface:

  1. client changes text in his browser on some form
  2. client-side javascript wraps it in a "commit" form
  3. client-side js send commit to remote private git server.

I guess I can give it a different spin:

  1. client changes text in his browser.
  2. sends changes to remote server (eg Node.js)
  3. Node.js bundles the changes to "a commit" form and sends it to git server.

Are there modern javascript libraries for this kind of things? Thanks.

jsgit seems to be the most widely used implementation.

BTW I would suggest having a backend (node.js + Express eg) that talks with the git repository.

Not sure if you can make git changes from js, but you can definitely do the following:

  1. Create a diff in the browser using google/diff-match-patch js implementation
  2. Submit this diff to remote server
  3. Process the diff on the server into git by doing git apply

git apply from-browser.patch

Note: I'm not a 100% sure that the formats would be compatible out of the box, so that's something you'd need to check.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM