git command
-
Upload
learningtech -
Category
Technology
-
view
213 -
download
0
Transcript of git command
Git CommandJason
git work
index.html git index repository
git add index.html git commit ….
git config
Config file location: system、 global、 local
git config --global user.name "your name"
git config --global user.email "[email protected]"
git init
This command creates an empty Git repository - basically a .git directory with subdirectories for objects, refs/heads, refs/tags, and template files. An initial HEAD file that references the HEAD of the master branch is also created.
git status
Displays paths that have differences between the index file and the current HEAD commit, paths that have differences between the working tree and the index file, and paths in the working tree that are not tracked by Git
git add
This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit.
git add index.html index.css
git add .
git add --update
.gitignore file
A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected;
.gitignore content
*.css!*.min.cssabc/*.txt**/foo/bara/**/b
git resetReset current HEAD to the specified state
git reset
git reset index.html
git commit
Stores the current contents of the index in a new commit along with a log message from the user describing the changes
git commit -m "commit message"
git commit --amend
git log
Shows the commit logs
git log
git log --stat
git log index.html
git log --author=’user name’
git command
git initgit configgit addgit resetgit commitgit log
git branchgit checkoutgit merge
Basic Branching and Merging ( 1 / 8 )
Basic Branching and Merging ( 2 / 8 )$ git branch iss53
$ git checkout iss53
Switched to a new branch 'iss53'
equivalent to
$ git checkout -b iss53
Switched to a new branch 'iss53'
Basic Branching and Merging ( 3 / 8 ) $ vim index.html
$ git commit -a -m 'added a new footer [issue 53]'
Basic Branching and Merging ( 4 / 8 )$ git checkout master
Switched to branch 'master'
$ git checkout -b hotfix
Switched to a new branch 'hotfix'
$ vim index.html
$ git commit -a -m 'fixed the broken email address'
Basic Branching and Merging ( 5 / 8 )$ git checkout master
$ git merge hotfix
Updating f42c576..3a0874c
Fast-forward
README | 1 -
1 file changed, 1 deletion(-)
Basic Branching and Merging ( 6 / 8 )$ git branch -d hotfix
Deleted branch hotfix (was 3a0874c).
$ git checkout iss53
Switched to branch 'iss53'
$ vim index.html
$ git commit -a -m 'finished the new footer [issue 53]'
Basic Branching and Merging ( 7 / 8 )$ git checkout master
$ git merge iss53
Auto-merging README
Merge made by the 'recursive' strategy.
README | 1 +
1 file changed, 1 insertion(+)
Basic Branching and Merging ( 8 / 8 )$ git checkout master
$ git merge iss53
Auto-merging README
Merge made by the 'recursive' strategy.
README | 1 +
1 file changed, 1 insertion(+)
Reference
https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
git command
git initgit configgit addgit resetgit commitgit log
git branchgit checkoutgit mergegit rebasegit revertgif diff