Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8937407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:24:39+00:00 2026-06-15T10:24:39+00:00

I am writing a script to automate setting up new projects for me. this

  • 0

I am writing a script to automate setting up new projects for me.

this includes pulling down a github repository.

What I want to do is have some output from my script, then call git clone $repo

I want to show the output from that command while it is running, but then when it has run if it has run successfully replace it’s output (note just the git commands output, I still want the output from before that to be there) with repository successfully cloned and if failed just leave the output there, and print repository cloning failed.

How can I do this?

Below is my current (rather simple) script.

#! /bin/bash

# -p project name

templateurl="git@bitbucket.org:xxx/xxx-site-template.git"

while getopts ":p:" opt; do #eventually I'll add more options here

case $opt in
  p)
    project=$OPTARG
    ;;
  \?)
    echo "Invalid option: -$OPTARG" >&2
    exit 1
    ;;
  :)
    echo "Option -$OPTARG requires an argument." >&2
    exit 1
    ;;
esac
done

if [ -z "$project" ]; then
    echo "Project name required"
    exit 1
fi

clear
echo "|==========================|"
echo "| New xxx Project Creator  |"
echo "|==========================|"
echo "Project: $project"

if [ -d "$project" ]; then
    echo "Directory $project already exists!"
    exit 1
fi


mkdir $project
if [ ! -d "$project" ]; then
    echo "Failed to create project directory!"
    exit 1
fi

echo "Cloning xxx Template repository"
git clone $templateurl $project
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:24:40+00:00Added an answer on June 15, 2026 at 10:24 am

    git clone does provide a exit code you can read with $? like follows:

    git clone user@server:repo
    echo $?
    

    This will print 0 if everything worked just fine. If for example the folder is not a git repository you will get the exit code 128.

    you can check if the clone worked as follows:

    git clone user@server:repo localrepo --quiet
    success=$?
    if [[ $success -eq 0 ]];
    then
        echo "Repository successfully cloned."
    else
        echo "Something went wrong!"
    fi
    

    --quietwill suppress any output from git, as long as there are no errors. So if you just remove the else-branch you will get you positive output or the error produced by git.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a script to automate the process of setting up a bunch
I'm writing a script to automate some merge operations and I'd like to do
I am new to python and am writing some scripts to automate downloading files
I'm writing a script to automate some command line commands in Python. At the
I am writing a Windows batch script in order to automate the process of
I'm writing script in remote.ini The script looks like on 1:start:{ server some.irc.server server
I'm writing a script that will constantly scan iTunes for new dialog boxes and
I was writing this small script the other day.It is a small program which
I'm writing an applescript to automate some tedious work in Aperture, and I'm having
I am writing a script to automate my iOS building. It will be run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.