Git command quick reference - perrigoh/learner_journal GitHub Wiki

WIP: Usable

Git command quick reference

A list of frequently used git commands for quick reference. For a complete list of git commands refer git Documentation under Reference section.

Create a repository

  • Initialise local repository without GitHub remote repository.

Steps:

  1. Change directory to the directory (folder) where the project is to be stored:

    $ cd Google\ Drive/Colab\ Notebooks/test_learner_journal
    NO OUTPUT

    The prompt will change to from [wmxpg] ~ to [wmxpg] ~/Google Drive/Colab Notebooks/test_learner_journal

  2. Initialise the directory (folder):

    $ git init
    Initialized empty Git repository in C:/Users/wmxpg/Google Drive/Colab Notebooks/test_learner_journal/.git/
  3. Check the status:

    $ git status
    On branch main
    
    No commits yet
    
    nothing to commit (create/copy files and use "git add" to track)
    

The setup is completed.

  • Initialise local repository with GitHub remote repository.

Steps:

  1. Change directory to the directory (folder) where the project is to be store:

    $ cd Google\ Drive/Colab\ Notebooks/learner_journal/
    NO OUTPUT

    The prompt will change to from [wmxpg] ~ to [wmxpg] ~/Google Drive/Colab Notebooks/learner_journal

  2. Initialise the local directory (folder):

    $ git init
    Initialized empty Git repository in C:/...Google Drive/Colab Notebooks/learner_journal/.git/
  3. Check the status:

    $ git status
    On branch main
    
    No commits yet
    
    nothing to commit (create/copy files and use "git add" to track)
    
  4. Create an empty README file (local):

    $ echo > README.md
    NO OUTPUT
  5. Stage the README.md file (local):

    $ git add .
    warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
  6. Commit the changes with commit message (local) without going through the editor.
    -m stand for message, specify message 'docs (readme): initial commit':

    $ git commit -m 'docs (readme): initial commit'
     [main (root-commit) d95f5bd] docs (readme): initial commit
     1 file changed, 1 insertion(+)
     create mode 100644 README.md
  7. Log in to Github web interface to create a new repository name learner_journal. At the Quick setup page copy the repository HTTPS URL.

  8. Add a remote name for identifying the remote repository, commonly used name is origin although it can be any other name. Specify the remote repository's URL `https://github.com/perrigoh/learner_journal.git':

    $ git remote add origin https://github.com/perrigoh/learner_journal.git
    NO OUTPUT
  9. To ensure the remote name has been created.
    -v stand for verbose which means to display more details:

    $ git remote -v
    origin  https://github.com/perrigoh/learner_journal.git (fetch)
    origin  https://github.com/perrigoh/learner_journal.git (push)
    
  10. Push all the changes (git commit) in the local directory (folder) to remote repository name origin and branch name main.
    Note: Branch name main is more commonly used now than master.
    -u = --set-upstream is to add upstream tracking reference:

    $ git push -u origin main
    Enumerating objects: 3, done.
    Counting objects: 100% (3/3), done.
    Writing objects: 100% (3/3), 228 bytes | 228.00 KiB/s, done.
    Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    To https://github.com/perrigoh/learner_journal.git
    * [new branch]      main -> main
    branch 'main' set up to track 'origin/main'.

Note: -u set-upstream only needed when pushing the local repository to remote repository the first time, subsequent push use git push origin main will do. And if where to push the repository is not specify git push , then the default is origin.

Example of error message that occurred when pushing the local repository without setting the up-stream:

$ git push
fatal: The current branch gh-pages has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin gh-pages

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.

The setup is completed.

git clone a remote repository to local directory (folder)

For more pictorial instruction, refer to GitHub Docs.

To clone a remote repository to local computer.

Steps:

  1. Change directory to the folder (directory) where the cloned repository is to be stored. In this case the repository will be store in the Colab Notebooks folder in the Google drive:

    $ cd Google\ Drive/Colab\ Notebooks
    NO OUTPUT

    The prompt will change to from [wmxpg] ~ to ~/Google Drive/Colab Notebooks.

  2. Log in to Github web interface and navigate to the existing repository. Click on the green <> Code button and from the drop down copy the HTTPS URL.

  3. Clone the remote repository:

    $ git clone https://github.com/perrigoh/perrigoh.git
    Cloning into 'perrigoh'...
    remote: Enumerating objects: 6, done.
    remote: Counting objects: 100% (6/6), done.
    remote: Compressing objects: 100% (4/4), done.
    remote: Total 6 (delta 0), reused 4 (delta 0), pack-reused 0
    Receiving objects: 100% (6/6), done

    A new folder (directory) named perrigoh along with all the remote repository files had been copied to the local computer Google\ Drive/Colab\ Notebooks.

  4. Change directory to the newly create directory (folder):

    $ cd perrigoh
    NO OUTPUT

    The prompt will change to from [wmxpg] ~/Google Drive/Colab Notebooks to [wmxpg] ~/Google Drive/Colab Notebooks/perrigoh.

  5. Ensure those files in the remote repository have been downloaded. -a stand for all directories and files including those with a period in front (invisible) info source:

    $ ls -a
    ./  ../  .git/  .gitignore  README.md

    There are one .git/ folder with .gitignore file in it and one README.md file in the repository.

  6. After the usual editing of changes or add new files, stage the commit using git add . and git commit, push all the changes in the local directory (folder) to remote repository name origin and branch name main.

    Note: Branch name main is more commonly used now than master.

    -u = --set-upstream is to add upstream tracking reference:

    $ git push -u origin main
    Enumerating objects: 4, done.
    Counting objects: 100% (4/4), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 322 bytes | 107.00 KiB/s, done.
    Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    To https://github.com/perrigoh/perrigoh.git
    6a71f55..138c54e  main -> main
    branch 'main' set up to track 'origin/main'.

    Note: -u set-upstream only needed when pushing the local repository to remote repository the first time, subsequent push use git push origin main will do. And if where to push the repository is not specify git push , then the default is origin.

    Example of error message that occurred when pushing the local repository without setting the up-stream:

    $ git push
    fatal: The current branch gh-pages has no upstream branch.
    To push the current branch and set the remote as upstream, use
    
        git push --set-upstream origin gh-pages
    
    To have this happen automatically for branches without a tracking
    upstream, see 'push.autoSetupRemote' in 'git help config'.

The cloning process is completed.

Remove link between the local repository and the remote repository info source

Steps:

  1. Change directory to the directory (folder) where the local repository is:

    $ cd Google\ Drive/Colab\ Notebooks/image_classifier_pytorch_udacity
    NO OUTPUT

    The prompt will change to from [wmxpg] ~ to [wmxpg] ~/Google Drive/Colab Notebooks/image_classifier_pytorch_udacity

  2. Remove the remote name, all remote-tracking branches and configuration settings.
    rm = remove, origin the commonly used name representing remote repository:

    $ git remote rm origin
    NO OUTPUT
  3. Remove the FETCH_HEAD that is still pointing to Github:

    $ rm .git/FETCH_HEAD
    NO OUTPUT
  4. To check whether the link to remote repository has been removed. -v = --verbose to show the remote URL:

    $ git remote -v
    NO OUTPUT

No output means there is no link to remote repository. Example of output if there is link to remote repository:

$ git remote -v
origin  https://github.com/perrigoh/image_classifier_pytorch_udacity.git (fetch)
origin  https://github.com/perrigoh/image_classifier_pytorch_udacity.git (push)

git status

To check the which changes are unstage / stage / yet to commit:

$ git status
On branch add-torcheck
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    Image Classifier Project-test17.ipynb
        modified:   README.md

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Image Classifier Project-test19.ipynb
        __pycache__/

no changes added to commit (use "git add" and/or "git commit -a")

git branch

To check the current working branch:

$ git branch
* add-torcheck
  issue-8-parameter-pretrained-deprecated
  issue-9-rework-test18-ipynb
  main                     21.3.0

The branch with asterisk is the current working branch.

git branch new_branch

To add new branch to local repository.

Steps:

  1. Add a new branch:

    $ git branch rework-test20-ipynb
    NO OUTPUT
  2. Checkout current branch and move to the created branch:

    $ git checkout rework-test20-ipynb
    Switched to branch 'rework-test20-ipynb'
  3. Keep a habit to ensure git is pointing to the correct branch:

    $ git branch  
    add-torcheck  
    issue-8-parameter-pretrained-deprecated  
    issue-9-rework-test18-ipynb  
    main  
    * rework-test20-ipynb

To add new branch and checkout at the same time info source.
-b stand for create new branch, new branch name rework-test20-ipynb:

$ git checkout -b rework-test20-ipynb
Switched to new branch 'rework-test20-ipynb'

git add

To stage commit all the files:

$ git add . 
warning: in the working copy of 'Image Classifier Project-test19.ipynb',  
LF will be replaced by CRLF the next time Git touches it

or

To stage commit on selected file:

$ git add README.md
TODO: NO EXAMPLE AT THE MOMENT

git commit message using command

Using command to enter the commit message when there is no need to preview the changes before committing.
-m stand for message, specify message 'docs (readme): initial commit':

$ git commit -m 'docs (readme): initial commit'
[main (root-commit) d95f5bd] docs (readme): initial commit
1 file changed, 1 insertion(+)
create mode 100644 README.md

git commit message using VS Code editor

Using VS Code editor to enter the commit message gives a preview of changes that will be committed.

Steps:

  1. Record changes to the local repository:

    $ git commit
    hint: Waiting for your editor to close the file...  

    Note: The terminal will hang till commit message is entered and the editor is closed.

  2. VS Code editor pop up:

    # Please enter the commit message for your changes. Lines starting
    # with '#' will be ignored, and an empty message aborts the commit.
    #
    # On branch add-torcheck
    # Changes to be committed:
    # deleted:    Image Classifier Project-test17.ipynb
    # new file:   Image Classifier Project-test19.ipynb
    # modified:   README.md
    # new file:   __pycache__/helper.cpython-36.pyc
    # new file:   __pycache__/helper.cpython-39.pyc
    #
    

    Output in the terminal after VS Code editor is closed:

    [add-torcheck 045ec41] abort add torcheck
    5 files changed, 8 insertions(+), 5250 deletions(-)
    delete mode 100644 Image Classifier Project-test17.ipynb
    create mode 100644 Image Classifier Project-test19.ipynb
    create mode 100644 __pycache__/helper.cpython-36.pyc
    create mode 100644 __pycache__/helper.cpython-39.pyc

git push branch to remote

  • First time pushing local repository to remote repository, requires setting up stream. Add a remote name originfor identifying the remote repository and the branch name add-torcheck to be pushed.
    -u = --set-upstream is to add upstream tracking reference:

    $ git push --set-upstream origin add-torcheck
    Enumerating objects: 9, done.
    Counting objects: 100% (9/9), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (7/7), done.
    Writing objects: 100% (7/7), 749.55 KiB | 9.61 MiB/s, done.
    Total 7 (delta 3), reused 0 (delta 0), pack-reused 0
    remote: Resolving deltas: 100% (3/3), completed with 2 local objects.
    remote: 
    remote: Create a pull request for 'add-torcheck' on GitHub by visiting:
    remote:      https://github.com/perrigoh/image_classifier_pytorch_udacity/pull/new/add-torcheck
    remote:
    To https://github.com/perrigoh/image_classifier_pytorch_udacity.git
    * [new branch]      add-torcheck -> add-torcheck
    branch 'add-torcheck' set up to track 'origin/add-torcheck'.
  • Subsequent pushing local branch (add-torcheck) to remote branch (origin/add-torcheck):

    $ git push origin add-torcheck
    Enumerating objects: 18, done.
    Counting objects: 100% (14/14), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (8/8), done.
    Writing objects: 100% (8/8), 927 bytes | 927.00 KiB/s, done.
    Total 8 (delta 6), reused 0 (delta 0), pack-reused 0
    remote: Resolving deltas: 100% (6/6), completed with 5 local objects.
    To https://github.com/perrigoh/image_classifier_pytorch_udacity.git
    a376ce5..ea3f1f7  add-torcheck -> add-torcheck  

Store unwanted branches in close pull request (info source)

Login to GitHub repository
Step 1. Create a Pull Request
Go to the "New pull request" page on the Github and create a pull request.
Step 2. Set the right name Name your pull request the same as your source branch.
Example: “feature_123”.
Step 3. Cancel this pull request
Yes, do not merge it! Scroll down and find "Close pull request". Close it without merge.
Step 4. Delete the branch
Now you can safely delete the branch.
Step 5. How to restore? At any time, when you will need it, simply find your closed pull request on the "Pull requests" page by the filter: “head:feature_123”. Open the pull request page and press "Restore branch" button. All the working process in the branch was successfully restored!

git checkout branch_name

Switching from the current branch to another branch name main:

$ git checkout main
Switched to branch 'main'
Your branch is up to date with 'origin/main'.

Delete branch local branch after merge and push to remote

-d stand for delete, specify the branch name rework-test20-ipynb to delete:

$ git branch -d rework-test20-ipynb  
Deleted branch rework-test20-ipynb (was 811a21c).

For deleting multiple branches add a space followed by the additional branch name
git branch -d branch-1 branch-2 branch-3

Delete remote branch

info source

Steps:

  1. Delete the remote branch. -d stand for delete, specify the remote name origin and the branch name website to delete:

    $ git push -d origin website
    To https://github.com/perrigoh/test_mkdocs_create_gh_pages.git
    - [deleted]         website

Depending on which version of Git, the local repo may still retain a remote reference (Git’s remote tracking branch) that points to the deleted remote branch.

  1. The prune option removes any remote tracking branch in the local repository that points to the deleted remote branch.

    $ git fetch origin --prune
    NO OUTPUT

or

  1. TODO Delete the remote tracking:

    $ git branch --delete --remotes origin/branch-name 
    YET TO TRY
  2. Delete the remote branch. -d stand for delete, specify the remote name origin and the branch name website to delete:

    $ git push -d origin website
    To https://github.com/perrigoh/test_mkdocs_create_gh_pages.git
    - [deleted]         website

git log

To check the commit history.

  • List all logs with details:

    $ git log
    commit 4d24fae7d8ab5a6125c7ce9d45585f393ac1654f (HEAD -> main, origin/main)
    Author: Perri Goh <[email protected]>
    Date:   Tue Nov 1 02:43:43 2022 +0800
    
        gitignore file

    Arrow up/down to see the next section, hit 'q' to quit when done.

  • List all logs by one line:

    $ git log --oneline
    4d24fae (HEAD -> main, origin/main) gitignore file
    8bd3adf fix: run command with/without flag and arg train.py and predict.py able to run command with/without flag and argument
    281f24e fix: rebuild model with saved arch
    04407fc fix: build model and train model in one file
    1fbcfc6 fix: type error
    8e1ee88 fix: program run on default arg if not specified

    Arrow up/down to see the next section, hit 'q' to quit when done.

  • List all logs by oneline with graph:

    $ git log --oneline --decorate --graph --all
    * 045ec41 (origin/add-torcheck, add-torcheck) abort add torcheck
    * 4d24fae (HEAD -> main, origin/main) gitignore file
    | * be1f410 (origin/issue-9-rework-test18-ipynb, issue-9-rework-test18-ipynb) abort rework ipynb keep branch as ref errors occur while editing: loss values become strange for vgg16, vgg13 is fine !python3 train.py --arch vgg16 --hidden_units 4096 --learning_rate 0.01 --epochs 1 Epoch: 1/1 Train Loss: -171548999680.000000, Valid Loss: -129730248704.000000, Train Accuracy: 0.009615 Epoch: 1/1 Train Loss: -171548999680.000000, Valid Loss: -148130955264.000000, Train Accuracy: 0.009615
    |/
    | * d54a16c (origin/issue-8-parameter-pretrained-deprecated, issue-8-parameter-pretrained-deprecated) fix: userwarning pretrained deprecated
    |/
    * 8bd3adf fix: run command with/without flag and arg train.py and predict.py able to run command with/without flag and argument
    * 281f24e fix: rebuild model with saved arch

    Arrow up/down to see the next section, hit 'q' to quit when done.

git reflog

Shows the record of when the tips of branchs and other references were updated in the local repository. HEAD@{2} means where HEAD used to be two moves ago info source:

$ git reflog
6ffb964 (HEAD -> main, origin/main) HEAD@{0}: pull: Merge made by the 'ort' strategy.
b353f1d HEAD@{1}: commit (amend): Merge remote-tracking branch 'origin/main'
ea3f1f7 HEAD@{2}: merge origin/main: Merge made by the 'ort' strategy.
268ced2 HEAD@{3}: commit: refactor: specific interpreter
4988645 HEAD@{4}: reset: moving to HEAD~1
446e666 HEAD@{5}: commit (merge): Merge branch 'main' of https://github.com/perrigoh/image_classifier_pytorch_udacity

Arrow up/down to see the next section, hit 'q' to quit when done.

git show info source

  • View the last log details and diff:

    $ git show
    commit 2811b79b21499144a32a57524ac37146dd30294b (HEAD -> main, origin/main)
    Author: Perri Goh <[email protected]>
    Date:   Sun Nov 13 12:50:32 2022 +0800
    
        docs(site):initial commit
    
    diff --git a/gh_pages/docs/index.md b/gh_pages/docs/index.md
    new file mode 100644
    index 0000000..000ea34
    --- /dev/null
    +++ b/gh_pages/docs/index.md
    @@ -0,0 +1,17 @@
    +# Welcome to MkDocs
    +
    +For full documentation visit [mkdocs.org](https://www.mkdocs.org).
    +
    +## Commands
    +
    +* `mkdocs new [dir-name]` - Create a new project.
    ...
    \ No newline at end of file

    Arrow up/down to see the next section, hit 'q' to quit when done.

  • View log details and diff with specific hash (SHA):

    $ git show 76061a7
    commit 76061a726a8444aa14d403530d90b4ec6064cd6a
    Author: Perri Goh <[email protected]>
    Date:   Sun Nov 13 12:44:53 2022 +0800
    
        docs: build site
    
    diff --git a/.gitignore b/.gitignore
    index 9eaa8f1..cdc5c2d 100644
    --- a/.gitignore
    +++ b/.gitignore
    @@ -9,3 +9,37 @@ __pycache__/
    
    # Jupyter Notebook
    .ipynb_checkpoints
    +
    +# Build Site
    +gh_pages/site/
    +gh_pages/site/404.html
    ...
    \ No newline at end of file

    Arrow up/down to see the next section, hit 'q' to quit when done.

Add changes/files to last commit

Steps:

  1. Stage the commit first, followed by:

    $ git add . 
    warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it

    or

    Add selected files to commit

    $ git add README.md
    NO OUTPUT
  2. Amend the commit message via VS Code editor:

    $ git commit --amend
    TODO: NO EXAMPLE AT THE MOMENT

    or

    Use the same previous commit message:

    $ git commit --amend --no-edit
    [main 4290d1d] docs (readme): rephrase content
    Date: Thu Dec 29 09:55:46 2022 +0800
    1 file changed, 2 insertions(+), 2 deletions(-)

Log search using filter

Search for commit message with a specific word:

$ git log --grep=fix
or
$ git log --grep fix
commit b578d2d918a8e6d8ffd5c929104b5da061c644eb
Author: Perri Goh <[email protected]>
Date:   Wed Nov 2 14:17:37 2022 +0800

    fix: rebuild model

Arrow up/down to see the next section, hit 'q' to quit when done.

git revert back to specific hash (SHA) info source

Better to use git revert for remote repository as it will create a hash (SHA) for the removal, hence the previous records is still intact:

$ git revert 7d2e50d
[main c35bf11] Revert "docs (readme): add content"
 1 file changed, 25 deletions(-)

Log after revert:

$ git log --oneline --decorate --graph --all
* c35bf11 (HEAD -> main) Revert "docs (readme): add content"
* 2811b79 (origin/main) docs(site):initial commit
* 76061a7 docs: build site
| * 76b0cf4 (origin/gh-pages, status, gh-pages) docs(site): gitignore
| * bc3707f Deployed 7d2e50d with MkDocs version: 1.4.2
...
* cd7d4dc initial commit

git reset back to specific hash (SHA) info source

To premenantly remove --hard the previous log (note: ensure that there are no changes in the remote (origin) before the specified hash):

$ git reset --hard 7d2e50d
HEAD is now at 7d2e50d docs (readme): add content

Log after reset --hard:

$ git log --oneline --decorate --graph --all
* 76b0cf4 (origin/gh-pages, status, gh-pages) docs(site): gitignore
* bc3707f Deployed 7d2e50d with MkDocs version: 1.4.2
| * 2811b79 (origin/main) docs(site):initial commit
| * 76061a7 docs: build site
|/
* 7d2e50d (HEAD -> main) docs (readme): add content
* 203b254 docs(license): initial commit
...
* cd7d4dc initial commit  

Remember to update the changes to remote (origin) using git push -f origin main.

Undo a merge commit (info source)

Steps:

  1. Check the log to get the SHA that is before merge:

    $ git reflog
    8853c9a (HEAD -> main, origin/main) HEAD@{0}: commit (merge): docs (readme): Changes to documentation
    fdce63c HEAD@{1}: commit (amend): docs (readme): add content
    85bf49a HEAD@{2}: commit: docs (readme): add content
    203b254 HEAD@{3}: commit: docs(license): initial commit
    400002b HEAD@{4}: commit: add project files
    e9b81ee HEAD@{5}: commit: docs: gitignore
    cd7d4dc HEAD@{6}: commit (initial): initial commit
  2. Reset to the previous commit before merge:

    $ git reset --merge fdce63c
    NO OUTPUT

    or

    $ git reset --merge HEAD~1
    NO OUTPUT 
  3. Force push to remote repository:

    note: force push only when very sure that there is no other commit after the (wrongly) merge commit in the remote (orign/main)

    $ git push -f origin main
    Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
    To https://github.com/perrigoh/classify_dog_pytorch.git
    + 8853c9a...fdce63c main -> main (forced update)  
  4. Final check both local (main) and remote (origin/main) HEAD are at the same SHA:

    git reflog
    4988645 (HEAD -> main, origin/main) HEAD@{0}: reset: moving to HEAD~1
    446e666 HEAD@{1}: commit (merge): Merge branch 'main' of https://github.com/perrigoh/image_classifier_pytorch_udacity
    4988645 (HEAD -> main, origin/main) HEAD@{2}: commit (amend): readme: update content
    db0c3ba HEAD@{3}: commit: readme: update content
    5504b5d HEAD@{4}: commit: check train.py and predict.py error free  

Merge differences between remote (origin/main) and local(main) repository

Steps:

  1. Check the status:

    $ git status
    On branch main
    Your branch and 'origin/main' have diverged,
    and have 1 and 1 different commits each, respectively.
    (use "git pull" to merge the remote branch into yours)
    
    nothing to commit, working tree clean
  2. Check what are the differences:

    $ git log --oneline --decorate --graph --all
    * a376ce5 (origin/main) docs (readme): add license shields
    | * 268ced2 (HEAD -> main) refactor: specific interpreter
    |/
    * 4988645 readme: update content
    * 5504b5d check train.py and predict.py error free

    Remote (origin/main) is at SHA a376ce5 and local (main) is at SHA 268ced, in this case use git fetch instead of git pull.

  3. Copy the remote (origin/main) to local (main):

    $ git fetch origin main
        From https://github.com/perrigoh/image_classifier_pytorch_udacity
    * branch            main       -> FETCH_HEAD
  4. Merge the copied origin/main which is now in the local with local (main)

    $ git merge origin/main
    Merge made by the 'ort' strategy.
    README.md | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)  
  5. Update the remote repository to be the same as local repository:

    $ git push origin main
    Enumerating objects: 18, done.
    Counting objects: 100% (14/14), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (8/8), done.
    Writing objects: 100% (8/8), 927 bytes | 927.00 KiB/s, done.
    Total 8 (delta 6), reused 0 (delta 0), pack-reused 0
    remote: Resolving deltas: 100% (6/6), completed with 5 local objects.
    To https://github.com/perrigoh/image_classifier_pytorch_udacity.git
    a376ce5..ea3f1f7  main -> main  
  6. Check status ensure HEAD is pointing to both main (local) and origin/main (remote)

    git log --oneline --graph --all
    *   ea3f1f7 (HEAD -> main, origin/main) Merge remote-tracking branch 'origin/main'
    |\
    | * a376ce5 docs (readme): add license shields
    * | 268ced2 refactor: specific interpreter
    |/
    * 4988645 readme: update content
    * 5504b5d check train.py and predict.py error free

git push -f origin main error: Protected branch

Error example:

$ git push -f origin main
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: error: GH006: Protected branch update failed for refs/heads/main.
remote: error: Cannot force-push to this protected branch
To https://github.com/perrigoh/classify_dog_pytorch.git
 ! [remote rejected] main -> main (protected branch hook declined)
error: failed to push some refs to 'https://github.com/perrigoh/classify_dog_pytorch.git'

info source On GitHub.com, navigate to the main page of the repository. Under your repository name, click Settings. In the "Code and automation" section of the sidebar, click Branches. To the right of the branch protection rule you want to delete, click Delete.

Add programme files to .gitignore

Use Toptal | gitignore.io to generate list of files not to be track base on Operation Systems, IDEs or Programming Languages. Copy and paste those that are relevant into .gitignore.

TODO ### Git stashing Reference: https://git-scm.com/book/en/v2/Git-Tools-Stashing-and-Cleaning

⚠️ **GitHub.com Fallback** ⚠️