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

Microsoft Windows Server 2012 R2 Standard Evaluation Product Key

Microsoft Windows Server 2012 R2 Standard Evaluation D2N9P-3P6X9-2R39C-7RTCD-MDVJX DBGBW-NPF86-BJVTX-K3WKJ-MTB6V

ManageEngine ServiceDesk Plus - Reset password

Let's reset the default administrator's password to 'admin'

hmailserver: Notes from the field

hmailserver is one of free open source mail servers running on Microsoft Windows operating system.