How does shell capture git checkout command failure scenarios?

< H2 > problem description < / H2 >
while writing a shell script, I need to git checkout to a branch after cd to a directory.
however, in some cases, git checkout fails because the artificial modification file is not submitted.
< H2 > excuse me < / H2 >

should I judge that the execution of git checkout failed?

< H2 > current idea, but it seems to have no effect < / H2 >
if (cd abc/ && git checkout master); then
    echo "ok"
else
    echo "fail"
fi
Mar.17,2021

cd abc && git checkout master

if [ $? -eq 0 ]; then
  echo "ok"
else
  echo "fail"
fi

has a more stupid way. Get his output information.. If the statement is not a successful switch, it is considered a switching error.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b349e8-404b6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b349e8-404b6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?