Git Flashcards
Git init
$ git add filedirectoryName
Copies file or directory from working directory to staging area
//to add a specific file or directory, specify
$ git add filename
// for the entire directory
$ git add .
$ git Commit -m “commit message”
this command moves file/directory from staging area to repo(local).
-m flag is mandatory
$ git push origin <branchname></branchname>
sends a staged/commited file to a remote repo
Git push -u origin main http/::wwxxxxxxx
send Local Repo content to central repo(Github)
Git pull vs git clone
Git clone, when the repo is not in your Local Host
Git Pull, when you just want to mirror an updated change from a file in the remote repo
Git checkout
Pull Request
git log
gives a log of commits only
$ git branch -D branchname
Delet branch
$ git branch -a
List all branches, Local and remote
Git latest commit
“HEAD” is a reference to the currently checked out commit (i.e., the latest commit) in the repository. When you make a new commit, the HEAD is updated to point to the new commit, making it the latest commit in the branch you are currently on.
you can change head commit by using
$ git checkout <commit></commit>
origin/main
Remote centralized repo (GitHub.com)
git pull vs git clone
git clone: download content to my computer from the remote repo
git pull: just make a copy of the latest since i already have a previous version, in order to make further changes
Note: you cant do git pull for a repo you do not have locally
git fetch -a
The command git fetch -a is used in Git to fetch all remote branches from the remote repository. The -a flag is short for –all, which tells Git to fetch all branches, not just the ones you have locally. This command is useful when you want to update your local repository with all the latest changes from the remote repository.