Git by Patrik

Initialize a new Git repository

This script initializes a new Git repository, adds all files to the staging area, commits them with a message, and pushes the changes to the remote repository.

# This script initializes a new Git repository, adds all files to the staging area,
# commits them with a message, and pushes the changes to the remote repository.

# Initialize a new Git repository with main as the initial branch
git init --initial-branch=main

# Add the remote repository URL (replace <remote-url> with your actual remote repository URL)
git remote add origin <remote-url>

# Add all files in the current directory and its subdirectories to the staging area
git add .

# Commit the changes with a descriptive message
git commit -m "Initial commit"

# Push the committed changes to the remote repository, setting up main as the tracking branch
git push -u origin main

Make sure to replace <remote-url> with the actual URL of your remote repository. Additionally, ensure that Git is installed and properly configured on your system before running this script. This script can be saved as a .sh file and executed in a terminal.

Comments