💾 Archived View for gluonspace.com › doc › git_cheat_sheet.gmi captured on 2022-03-01 at 15:07:00. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Git cheat sheet

Setup basic variables

git config --global user.name "first_name last_name"
git config --global user.email "email"

Clone repo

git clone path_to_repo

Add and commit files

git add file_name
git commit [-m "message"]

or


git commit -a [-m "message"]

Create repo from local files

cd folder
git init
git add .
git commit

Fork a github repo

Navigate to the target repo and on the top-right corner click fork.

Navigate to your fork of the repo and copy the clone URL.

git clone https://github.com/your_username/repo.git

Syncing a github fork

Navigate to the target repo and copy the clone URL.

cd fork_folder
git remote -v
git remote add upstream https://github.com/fork_username/repo.git
git remote -v
git fetch upstream
git checkout master
git merge upstream/master

Create and checkout a new branch

git branch branch-name
git checkout branch-name

or

git checkout -b branch-name