Github Flashcards
How to check the current git CLI version?
git version
How to init a local git repository?
git init [(repo_name)]
With (repo_name), it creates a folder instead.
What is a stash in github?
Its a snapshot of a state that is stored for later use, after creating one, the working dir returns to the previous commit state.
How to create a stash in git CLI?
git stash
How to seek help for a git command?
git help [(command_name)]
if no command_name is specified, git shows general commands help.
How to set the current username and password of the git user on the global level?
git config –global user.name (name) and
git config –global user.email (email).
How to clone a github repo?
git clone (repo.git)
how to list a git config in the console
git config –list
how to add to the staging area: a single file, all files
git add (filename) | git add .
How to commit a staging area?
git commit -m or git commit, to comment with an editor
How to express add all already tracked files and commit then?
git commit -am “message”
How to open the config file with the chosen editor
git config -e
Where is the global and local git config file stored?
global: C:/Users/Youruser/.gitconfig
local: inside the .git folder
What is the usefulness of git pull (repo) [(branch)]?
to put your local repo in sinc with the remote one in case someone made a change before.
Whats the difference between fetch and pull?
Fetch only updated the references while pull updates the references and downloads the differences.
What is forking?
Forking means you will get a copy of a remote repo to your github ID (not to your local computer)
how to list all tracked files?
git ls-files
how to unstage files?
git restore –staged
how to remove newly created files from working dir
git restore (filename)
how to move/rename files?
git mv (actual_dir/name) (new_dir/name)
why is the command git add -A useful?
If renaming or changing dir of files without using git mv, the git will see that as two operations: the deletion of a file, and the addition of another, it cannot match the index of the two operations as if it belongs to the same file, thus creating a new file index if you decide to commit.
This can lead to problems when pulling for example, because instead of replacing a file with index X, it may replace another file with another index instead.
how to remove any git files?
git rm (filename)
how to log git commits?
git log
how to log git commits in one line?
git log –oneline
how to log git commits from a author?
git log –author=”(name)”
how to log git commits by date?
git log –since=’x days ago / dd/[mm]/[yy]’
how to log git commits with graphics?
git log –graph
how to log git commits of a specific file?
git log (filename)
how to log git commits for a specific file even if the file was renamed at one point?
git log –follow (filename)
what are git aliases and how to create one?
are ways of shortcuting commands
to create:
git config [–global] alias.(commandName) “(command)”
*(command) excludes the initial ‘git’ from beginning of line.
how to ignore some files?
creating a .gitignore file and placing paths to the folders/files
how to log git commits across all branches?
git log –all