Skip to main content

Learn: git - 'the stupid content tracker'

Linus Torvalds named git in man page as "the stupid content tracker".

"Git was created by Linus Torvalds, the creator of the Linux kernel, in 2005. Torvalds was dissatisfied with the existing version control systems available at the time, and he wanted a system that could handle the scale and distributed nature of Linux development. Git is a distributed version control system, which means that each user has a complete copy of the repository. This makes it very efficient for collaborating on projects, as users can work on their own copies and then easily merge their changes back into the main repository." — bard.google.com

$ man giteveryday

Init git repository

git init

Add all files and folders of current path to repository

git add .

Commit to repository

git commit -m 'First commit'

What happened?

git log
git log --oneline

List all branches

git branch -a

Create and checkout a new branch with one command

git checkout -b branch_name

Clone repository

git clone

Pull repository

git pull

Reset all local changes permanently

git reset --hard

Accidently delete files

Run git checkout -- to list deleted files

PS F:\Projects\github\cloudconeapi> git checkout --
D       .gitignore
D       LICENSE
Your branch is up to date with 'origin/master'.
PS F:\Projects\github\cloudconeapi>

Git Cheat Sheet

git --version
git --help
git config --global user.name
git config --global user.email
git config --list
git clone
git pull
git pull -a : pull all branches
git add
git commit
git push
git clean
git remote add <url>
git remote rm <reponame>
git remote -v
git ls-files --deleted
git checkout -- <file>
git checkout branch-name-here
git branch --delete branch-name-here
git rm --cached .env
git rm -r --cached vendor

git clean untracked files

PS F:\Projects\github\lthwnodejs> git clean -i -d                                                
Would remove the following item:
  node_modules/
*** Commands ***
    1: clean                2: filter by pattern    3: select by numbers
    4: ask each             5: quit                 6: help
What now> c
Removing node_modules/
PS F:\Projects\github\lthwnodejs>   

.gitignore file must use UTF-8 encoding

I once have no idea why one of my .gitignore files was encoded as UTF-16 LE. So all untracked files keep showing and cannot use 'git add .' to add all new/modified files. Search google to find solution and then change encoding to UTF-8 solved my issue.

Learn Version Control with Git

This is a step-by-step course for the complete beginner.

https://www.git-tower.com/learn/git/ebook/en/command-line/introduction

Learn Git on Codecademy

https://www.codecademy.com/learn/learn-git

SAP Cloud Platform Version Control with Git by Arnaldo Cavazos on open.SAP.com

https://open.sap.com/courses/git1

Read giteveryday man page

giteveryday - A useful minimum set of commands for Everyday Git

Version Control with Git on Coursera

https://www.coursera.org/learn/version-control-with-git

What esle to learn about git?

By the way, what does git means in English?

What git means in English

Popular posts from this blog

RHEL: Install MySQL

[tuyendq@DangQuocTuyen ~]$ sudo yum list mysql Loaded plugins: product-id, search-disabled-repos, subscription-manager Error: No matching Packages to list [tuyendq@DangQuocTuyen ~]$ sudo yum install mysql Loaded plugins: product-id, search-disabled-repos, subscription-manager Resolving Dependencies --> Running transaction check ---> Package mariadb.x86_64 1:5.5.60-1.el7_5 will be installed --> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.60-1.el7_5 for package: 1:mariadb-5.5.60-1.el7_5.x86_64 --> Running transaction check ---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================= Package Arch Version Repository Size ================================...

Who is logged on to Windows

query user Check who is logged on to Windows: query user In Linux: who

IBM Domino: Exprired password

Your account is locked out if you do not change your expired password. IBM Notes: Password is expired Account is locked out when password is expired Example of password policy