Sunday, November 8, 2020

Github - main branch

 create a new repository on the command line

echo "# next" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:tecknovice/next.git
git push -u origin main
                

 push an existing repository from the command line

git remote add origin git@github.com:tecknovice/next.git
git branch -M main
git push -u origin main

Monday, August 31, 2020

How do I discard unstaged changes in Git?

 Another quicker way is:

git stash save --keep-index --include-untracked

You don't need to include --include-untracked if you don't want to be thorough about it.

After that, you can drop that stash with a git stash drop command if you like.

---------------------------

It seems like the complete solution is:

git clean -df
git checkout -- .

git clean removes all untracked files (warning: while it won't delete ignored files mentioned directly in .gitignore, it may delete ignored files residing in folders) and git checkout clears all unstaged changes.