Learning Git

Resources for learning Git

git/git-workflow.jpeg

07 May 2022

ProGit

highly recommended read - helped me "unlock" my Git understanding

my book highlights

Pro Git, by Scott Chacon

Snippets

Get local repo from Git (clone)

Navigate first in terminal to folder where the cloned repo should be as a sub-folder, then:

git clone my_repo_url.git

Commit

git init

git add .
git commit -m "my first commit"

# 1st time
git remote add origin <remote repository URL>
git remote add origin https://github.com/ndeville/indeXee.git

git push origin main

OR 

git push origin HEAD:master

if ""error: src refspec master does not match any"

git init
git add .
git commit -m 'message'
git push -u origin master    

after this, if you still having that error, follow these steps again:

git add .
git commit -m 'message'
git push -u origin master 

git push origin HEAD:main

get repo updates

git pull origin main

rename Local Branch

git branch -m new-branch-name

eg.

git branch -m main

delete local branch

git branch -d  local_branch_name

list all branches

git branch -a

remote servers configured

git remote -v

add remote server

git remote add shortname url

shortname is optional

Usage:

git remote add [<options>] <name> <url>

    -f, --fetch           fetch the remote branches
    --tags                import all tags and associated objects when fetching
                          or do not fetch any tag at all (--no-tags)
    -t, --track <branch>  branch(es) to track
    -m, --master <branch>
                          master branch
    --mirror[=(push|fetch)]
                          set up remote as a mirror to push to or fetch from

completely uninitialize (ie remove, delete) Git from your Project

rm -rf .git

remove files that are listed in the .gitignore but still on the repository

You basically remove and re-add all files, but git add will ignore the ones in .gitignore:

git rm -r --cached .
git add .
git commit -m "Drop files from .gitignore"

size managememt

15 Mar 2023

My notes folder size is now 2.2Gb. Need to figure out how to manage this:

git/230315-notes-git-size.jpg

TODO

  1. what is the impact of a 1.3Gb .git folder?
  2. how to reduce the size of the .git folder?
  3. how to reduce the size of the pagefind index folder?

Resources

links

social