Git Complete Hands on Training for Web Developers by Deepika Khanna

What is Git?

Git is a version control system. It helps to manage changes to your files. It keeps track of what changes made to which file and who made those changes.


A Centralized Version Control System(CVCS) uses a central server to store all files.

A Distributed VCS enables every developer to get its own copy of the entire project.


Stability is the illusion of the unimaginative. So what's different? It's very simple. I had somebody who believe in me and I never gave up. If you can find somebody who believes in you, somebody who can look at you in the eye and tell you you're not stupid, you're not crazy, go for it, that changes everything.

Federico Pistono

git --version /*check current version of git installed.*/

 

pwd /*present the path of current working directory*/

 

ls /*list all files and folders under the current folder.*/

 

clear /*clear the screen.*/

 

git init /*initialize a git repository in the current folder.*/

 

ls -la /*list out all files and folders including those hidden ones.*/

 

git status /*check the status of each file in your depository.*/


Creating a git account:

 

git config --global user.name "Mike" /*define author's name*/

 

git config --global user.email "[email protected]" /*define author's email*/

 

git config --list /*list out content of the config file.*/


git add index.html /*stage a file for the next commit; Before completing the commit, the file can be formatted and reviewed in an intermediate area called staging area.*/

 

git commit -m "first commit of index file" /*commit staged files with a descriptive message.*/

 

git add . /*add all untracked files or changes not staged for commit.*/

 

git add blue.html orange.html /*staging two files.*/

 

git log /*view a repository's commit history*/

 

git log --oneline /*show git commit history one line for one commit*/

 

git log index.html /*show only commits related to one specific file.*/


git tag -a v1.0 -m "stable version of the website" /*give a tag to a specific version*/

git tag -a -m "" /*create an annotated tag pointing to the most recent commit.*/


git checkout v1.0 /*looking at a specific version*/

 

git checkout 7892597 /*looking at a specific version*/


git revert 7892597 /*revert a specific version*/

git revert /*undo the specific commit by applying a new commit*/


git reset --hard /*reset tracked file to match the most recent commit*/


git clean -f /*remove all untracked files*/


git branch /*list all existing branches.*/

 

git branch crazy /*create a branch called crazy.*/

 

git checkout crazy /*switch to branch crazy*/

 

git checkout master /*switch to master branch*/


将一个名为crazy.html的文件重命名为rainbow.html后的操作:

Git Complete Hands on Training for Web Developers by Deepika Khanna_第1张图片


Merge branch css to master:

1. first, switch to master branch:

git checkout master

2. then, use the following command:

git merge css

3. third, css branch is identical to master branch and can be deleted as a result:

git branch -d css


git checkout crazy

git merge master /*merge master branch to crazy branch*/

 

git commit -a -m " Add css Stylesheet to rainbow.html"

 

git about /*about 是个文件名;此命令可以把一个文件夹里的所有内容加到staging area*/

 

git branch -d news-hotfix /*delete a branch*/

 

git rebase master /*rebase off the updated version of master branch*/

git rebase /*Move the current branch's commits to the tip of */

 

git rebase -i master /*change commit history*/

git rebase -i /*Perform an interactive rebase and select actions for each commit*/

 

git commit --amend /*Add staged changes to the most recent commit instead of creating a new one.*/

git rebase --continue /*Continue a rebase after amending a commit*/

git rebase --abort /*Abort the current interactive rebase and return the repository to its former state*/

Rebasing enables fast-forward merges by moving a branch to the tip of another branch.


git checkout -b new-pages /*creage a new branch and switch to it.*/


Rules for commit:

Commit a snapshot for each significant addition to your project.

Don't commit a snapshot if you can't come up with a single, specific message for it.


git reflog /*Display the local, chronological history of a repository*/


When you are in "detached HEAD' state, the head is not in the tip of the branch.


git reset --mixed HEAD~ /*Move the HEAD backward commits, but don't change the working directory*/

git reset --hard HEAD~ /*Move the HEAD backward commits, and change the working directory to match*/

git log HEAD..green-page --stat /*show difference bewteen master and the branch green-page*/

git log .. /*Display the commits reachable from but not from . These parameters can be either commit ID's or branch names*/


git clone my-git-repo marys-repo /*cloning a repository*/

git clone /*Create a copy of a remote Git repository*/

ls /*list file names*/

ll /*list file name and related info*/

 

git log -n 1 /*check only the last commit*/

git remote /*show relationship with other depository; list remote repositories*/

git remote -v /*show remote repository's path*/

git remote add /*Add a remote repository*/

git remote add mary ../mary-repo /*establishing a connection with a repository known as mary, specifying its path*/

git fetch /*Download remote branch information, but do not merge anything*/

git fetch mary /* fetch all branches from mary*/

git branch -r /*show remote repository's branches*/

 

git log master ..mary/master --stat /*compare branches*/

git push /*Push a local branch to another repository*/

git push mary dummy /*push a branch dummy to repository*/

git push mary v2.0 /*push a tag to repository mary*/


git init--base /*Create a Git repository, but omit the working directory*/

git init --bare central-repo.git /*tell git to create a repository that don't include a working directory*/

 

git remote rm /*Remove the specified remote from your bookmarked connections*/

git remote rm origin /*remove connection with repository origin*/

 

git remote add origin ../central-repo.git /*add an origin*/


git config --list /*list out config content*/

你可能感兴趣的:(Git,Video,Tutorial,视频教程笔记,Git)