Skip to content

Instantly share code, notes, and snippets.

@draev
Forked from bleeckerj/git_cheatsheet.md
Last active November 11, 2022 15:04
Show Gist options
  • Save draev/6873435 to your computer and use it in GitHub Desktop.
Save draev/6873435 to your computer and use it in GitHub Desktop.

Set username
git config --global user.name "Your Name Here"

Set e-mail
git config --global user.email "your_email@example.com"

Clorize and make git output pretty
git config --global color.ui true

Creating a repository
git init

Create a file

touch README.md
echo "Hello World" > README.md

Git status
git status
The file README.md we added above will show as untracked

Git add
Let's add our README.md to staging area
git add README.md

Git commit
Commit what we have in staging area to repository
git commit -m "Adding a README"

Git add remote origin
Add a remote so that we can sync our local repository
git remote add origin https://github.com/username/Hello-World.git

Create a new branch
git branch readme_update

Checkout (switch) to new branch
git checkout readme_update

A shortcut!
Create readme_update branch & checkout
git checkout -b readme_update

What branch are we on?
git status or git branch

Make some changes to readme

Add to staging area
git add README.md

Git status
Do our changes to README show up in staging area?
git status

Git commit
git commit -m "Committing changes to readme"

Switch back to master
git checkout master

Merge our changes from readme_update branch in
git merge readme_update

Delete readme_update branch
git branch -d readme_update

@tinker1987
Copy link

tinker1987 commented Nov 11, 2022

Fetch grouped commits from log for release notes

git log --no-merges  --pretty=format:"%s (%cn)" origin/branch...origin/master | sort -uk2 | sort -nk1 | cut -f2-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment