Git
A version control system that tracks changes in computer files
A version control system that tracks changes in computer files
Code | Function |
---|---|
pwd | view current file path or location |
ls | view a list of files and folders in a directory |
explorer . | open the current directory in files (PC) |
code . | open the current directory in the text editor (PC) |
git add file_name | stage file for the next commit |
git add -A | stage all changed files for the next commit |
git commit -m "Explanatory message" | commit files in staging area to repo with a message |
Branches are used to trial a new feature or design which can then be merged into the main branch or easily deleted/pruned
Code | Function |
---|---|
git checkout branch-name | switches to the named branch |
git checkout -b new-branch-name | creates and switches to a new named branch |
git branch | list the branches in the local repo |
git branch -a | list all the branches in local and remote repos |
git branch -d branch_name | deletes the named branch (when abandonning a feature) |
git branch -m branch_name new_branch_name | rename a branch |
git branch -m branch_name new_branch_name | rename a branch |
git merge branch-name | merges commits from the named branch to the current branch |
git stash | temporarily stores changes so you can switch branches without committing changes and without losing your work |
git stash pop | apply the changes that were stored |
git clone | clone a remote repo to your computer (local) |
git push origin branch_name | push changes from a branch to a remote repo |
git remote -v | list the remote repos that are connected to your local repo |
git fetch | downloads any files or commits to the computer |
git remote remove origin | removes the origin connection |
Code | Function |
---|---|
mkdir directory_name | make a new directory and name it |
ls -a | view a list of files and folders in a directory including hidden and system files |
rm -r directory-name | remove a directory ⚠ THIS IS PERMANENT AND DELETES THE DIRECTORY AND CONTENTS |
touch file_name | creates a new file (touch index.html) |
git status | check for new, modified or untracked project files |
git log | shows a history of the commits to a project |
git diff | compare the recent changes to the previously/current committed version |
cp current-name new-file-name | duplicate a file |
cat | view all the content in a file from the command line |
rm file-name | ⚠ Permanently deletes the file |
Code | Function |
---|---|
cd | move into a directory |
cd .. | navigate up one directory |
cd ../.. | naviage back two directories |
cd - | return to your previous location |