Git Init Script for local Repo
You can create a new file, for example, named setup_repo.sh, and then add the following contents to it:
Prerequisites
- Install Git and configured
- Create a GitHub account.
- SSH access set up for GitHub.
Script
#!/bin/bash
# Add a title to the README.md file
echo "# prueba" >> README.md
# Initialize a new Git repository
git init
# Add README.md to the staging area
git add README.md
# Commit the changes with a message
git commit -m "first commit"
# Rename the default branch to main
git branch -M main
# Add a remote repository
git remote add origin git@github.com:UserName/prueba.git
# Push changes to the main branch of the remote repository
# And set it to track the upstream branch
git push -u origin main
-
Make sure to grant execute permissions to your script by running:
chmod +x setup_repo.sh
-
You can then run the script from your terminal with:
./setup_repo.sh
This script assumes you have Git configured and SSH access set up for GitHub. Adjust the GitHub repository URL if necessary.
GitHub web web: https://docs.github.com/