This repository serves as a way for me to practice using Git and GitHub. It contains notes from the Git and GitHub Master Class by Shubham Londhe, as well as some commands that I have been practicing.
Here are some of the Git commands and its descriptions:
git init
: Creates an empty Git repositorygit remote add origin https://github.com/virginiabrioso/repoName.git
: Creates a new repository on the command line or connects a folder to an existing repositorygit add .
orgit add specificFile.txt
: Adds files to a commitgit commit -m "message"
: Adds a comment that explains why/what you are changinggit branch develop
: Creates a new branch locallygit push -u https://github.com/virginiabrioso/repoName.git develop
: Pushes the new branch into the remote repositorygit push
orgit push origin main
orgit push origin HEAD:refs/for/develop
: Publishes your commitgit branch -M main
: Renames the current branch to main, even if this branch already existsgit branch -d develop
: Deletes a branchgit checkout -b develop
: Creates a change to the develop branch, creating it if it doesn't existgit pull
: Gets updates from the remote repo and brings those changes from the remotegit pull origin master --rebase
: Updates the base code of your commit to the most recent version of base codegit fetch
: Retrieves the latest metadata info from the original (but doesn’t transfer any files)git merge develop
: Merges your feature branch into the base branchgit status
: Shows the user which branch and commit they are on, as well as tracked/untracked filesgit cherry-pick commitSha
: Moves a commit from one branch to anothergit stash
: Saves uncommitted changesgit stash apply
: Takes the changes you have stored in a stash and applies them to the working directorygit stash pop
: Same as above, but deletes the stash after the changes have been appliedgit stash clear
: Deletes all saved stashes
- Branch: A ramification from a certain point of code. For a general idea, imagine that Git is a tree. The trunk would be the base code, and branches are the ramifications based on this (note that not every branch has to have the same base code).
- For commits, there are common patterns that most developers use. You can read more about this here.
- The first time you push to your remote, do it like this:
git push -u origin develop
. The-u
flag stands for--set-upstream
. After the first time, you only need to do it like this:git push
.