cd- change directorymkdir- make a new directorylsordir- list directory contentsrmordel- delete one or more files
$ mkdir my-repo $ cd my-repo
2 May 2021
cd - change directorymkdir - make a new directoryls or dir - list directory contentsrm or del - delete one or more files$ mkdir my-repo $ cd my-repo
For grabbing a remote repo
$ git clone https://github.com/BroVic/my-repo.git Cloning into 'my-repo'... remote: Enumerating objects: 3, done. remote: Counting objects: 100% (3/3), done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. Checking connectivity... done. $
Check the current status of a git repo
$ git status fatal: Not a git repository (or any of the parent directories): .git
To check
$ git config --get user.name $ git config --get user.email
To set
$ git config --global user.name "User Gitter" $ git config --global user.email "user.gitter@myemail.com"
To initialize or create a Git repo (locally)
$ git init Initialized empty Git repository in C:/Users/Admn/Documents/project/my-repo/.git/ $ git status On branch master Initial commit nothing to commit (create/copy files and use "git add" to track)
Related to working with the remote repo
$ git remote add origin https://github.com/BroVic/my-repo.git
To check the remote repo
$ git remote -v origin https://github.com/BroVic/my-repo.git (fetch) origin https://github.com/BroVic/my-repo.git (push)
After committing changes, you can push them to a remote repo.
$ git push origin master
To work with branches
$ git branch * master $ git branch dev $ git branch dev * master
To change to another branch use the checkout option
$ git checkout dev Switched to branch 'dev' $ git branch * dev master
This is a 2-in-1 operation
git fetchgit mergeLet’s say we made a change on the remote repo…
Check if you want to include locally (Good practice!)
$ git fetch origin master remote: Enumerating objects: 5, done. remote: Counting objects: 100% (5/5), done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. From https://github.com/BroVic/my-repo * branch master -> FETCH_HEAD f8ee478..2bdf16e master -> origin/master
Use git diff to check the changes
If satisfied with changes, do a git merge
$ git merge Updating f8ee478..2bdf16e Fast-forward index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
git help$ git help
usage: git [--version] [--help] [-C <path>] [-c name=value]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
...
...
To find help for a given command, do `git help
$ git help clone Launching default browser to display HTML ...