Github Boilerplate for New Repositories

Create a new repository on the command line

echo "# github-new-repo-template" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/eugenevdm/github-new-repo-template.git
git push -u origin main

Push an existing repository from the command line

git remote add origin https://github.com/eugenevdm/github-new-repo-template.git
git branch -M main
git push -u origin main

How to use a personal access token from the command line

Simply user your Github username and for password, the actual token.

Set up an existing directory to pull from Git

git init
git remote add origin https://github.com/eugenevdm/github-new-repo-template.git
git pull origin main

Cheat Sheet

Start a main branch by default (requires Git 2.28):

git config --global init.defaultBranch main

https://superuser.com/questions/1419613/change-git-init-default-branch-name

Upgrade Git

On a new Ubuntu, you might get this:

sudo apt-get upgrade git
git is already the newest version (1:2.25.1-1ubuntu3.1).

Solution

sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install git -y
git --version

 

Tags

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top