Skip to Main Content

MongoByte MongoDB Logo

Welcome to the new MongoDB Feedback Portal!

{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.

Status Submitted
Categories MongoDB Shell
Created by Guest
Created on Oct 21, 2021

Support git command

MongoSh is a developer tool, obviously. So as a developer, git is always a part of it. Supporting git command inside mongosh will help us save a lot of time. Here's some of my implementation: ``` const git = (command) => { try { return execSync(`git ${command}`).toString(); } catch (e) {}; return null; }; const listBranches = () => { const branches = git(`branch -a`).split(/\r\n|\n|\r/).filter(notEmpty); return branches.map(branchObj); }; const pull = (remote = 'origin') => { return git(`pull ${remote} --rebase`); }; const log = (cnt) => { const _cnt = Number(cnt) || 32; return git(`log --graph --all --oneline --decorate=short --max-count=${_cnt}`); } ```