Languages
[Edit]
EN

Bash - detect if git project directory contains changes

7 points
Created by:
Emrys-Li
380

In this short article, we would like to show how to check if a project directory that uses Git contains some local changes.

Quick solution:

#!/bin/bash

if [ -n "$(git status --porcelain)" ];
then
    echo "Some local changes detected !!!"
else
    echo "There are no local changes."
fi

 

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join