Skip to content

Instantly share code, notes, and snippets.

@Gimpy3887
Last active January 4, 2025 01:24
Show Gist options
  • Save Gimpy3887/a013e1fbb1c6861ba1688470907c430f to your computer and use it in GitHub Desktop.
Save Gimpy3887/a013e1fbb1c6861ba1688470907c430f to your computer and use it in GitHub Desktop.
Notes on the essentials of github.

Configuring Credentials

git config --global --get user.email retrieves the user's global e-mail, remove global keyword for local retrieval. git config --global --get user.name retrieves the user's global username, remove global keyword for local retrieval.

Configuring with Multiple Accounts

Change to the second accounts enough before doing anything and then things fall into place with GCM.

git config user.name "Your Second Account Name"

git config user.email "[email protected]"

Commands Overview

git rm -r directory deletes the specified directory.

git rm -r file.ext deletes the specified file.

git branch shows all the branches.

git add -p cycles through all the changes and asks you which "hunk" of code you would want to make a commit for. Use s to keep breaking up the chunks, use q to quit because staging all the chunks doesn't mean you get to commit them one by one, and n to skip the chunk.

git checkout -b 'branchname' creates a new branch and takes you to it: there's a branch naming convention where branch names can include letters, numbers, dashes ( - ), underscores ( _ ), and dots ( . ), but they cannot begin with a dot or end with a slash ( / ). Git is case-sensitive, so Feature and feature are considered different branches.

git push -u origin your_branch sends the branch over to be cemented into the repository.

git clone repo_url clones a github repository including the history of the repo, downloading from github doesn't include the history.

git shortlog shows a short list of all the logs concerning users that have made changes to the repo: it only displays the first line of the commit.

Making the Best Commit in 6 Steps

1. Seperate Subject from Body

The subject of the body has to be seperated from the body with a blank line.

My subject line

Body text here.

2. Subject Must be Atmost 50 Characters

If the subject isn't equal to 50 characters, the rest of the text gets truncated.

3. First Word of the Subject Must Be a Capital Letter

Unsure what the reasoning is for this.

4. No Periods at the End of Subject Line

There cannot be any periods ending the subject line because it wastes precious space.

5. Command Tone in Subject Line

The command tone should be used in the subject line i.e. clean your room, close the door, and take out the trash. One tip for accomplishing this easily is to be able to complete the following sentence: If applied, this commit will your subject line here.

6. Wrap Description at 72 Characters

The description should start a new line every 72nd character.

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