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

Powershell: Get-ChildItem

List, search/find files and directories with Get-ChildItem cmdlet.

Java: Free Online Courses

The Java™ Tutorials by Oracle The Java Tutorials are practical guides for programmers who want to use the Java programming language to create applications. They include hundreds of complete, working examples, and dozens of lessons. Groups of related lessons are organized into "trails". https://docs.oracle.com/javase/tutorial/ Learn to Program in Java at edX.ogr Get started on the path to becoming a software engineer by learning core coding skills in Java—one of the most popular programming languages. https://www.edx.org/course/learn-to-program-in-java-0 Java Tutorial by javapoint.com https://www.javatpoint.com/java-tutorial Java Tutorial by SoloLearn.com I love SoloLearn because I can learn Java - and other popular programming languages - anywhere, any time on your mobile devices. https://www.sololearn.com/Course/Java/ Java on Azure https://docs.microsoft.com/en-us/learn/paths/java-on-azure/

Linux command: Check Current Shell

What is your current shell ?