###查看帮助文档 ``` git config --help git help config man git-config ``` ###windows环境下github免密码push(SSH方式) ``` liguodong@WIN-0HGJ9QM2MEG ~ $ ssh-keygen -t rsa -C "liguodongiot@163.com" #使用ssh-agent保存密码,避免每次上传都需要输入密码。 liguodong@WIN-0HGJ9QM2MEG ~ $ eval "$(ssh-agent -s)" Agent pid 632 liguodong@WIN-0HGJ9QM2MEG ~ $ ssh-add ~/.ssh/id_rsa Enter passphrase for /c/Users/Administrator/.ssh/id_rsa: Identity added: /c/Users/Administrator/.ssh/id_rsa (/c/Users/Administrator/.ssh/id_rsa) #将ssh-key添加到github账户上去 #打开id_rsa.pub,并复制里面的内容到github上去 liguodong@WIN-0HGJ9QM2MEG ~ $ vim ~/.ssh/id_rsa.pub # 验证是否成功 liguodong@WIN-0HGJ9QM2MEG ~ $ ssh -T git@github.com Warning: Permanently added the RSA host key for IP address '192.30.252.129' to the list of known hosts. Hi liguodongIOT! You have successfully authenticated, but GitHub does not provide shell access. #查看当前推送方法 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/liguodongiot.github.io (master) $ git remote -v liguodongiot@163.com git@github.com:liguodongIOT/liguodongiot.github.io.git (fetch) liguodongiot@163.com git@github.com:liguodongIOT/liguodongiot.github.io.git (push) origin https://github.com/liguodongIOT/liguodongiot.github.io.git (fetch) origin https://github.com/liguodongIOT/liguodongiot.github.io.git (push) 修改将https改为ssh的方式 git remote set-url origin git@github.com:liguodongIOT/liguodongiot.github.io.git ``` ###TortoiseGit连接github免密码push(HTTPS方式) ``` 当你配置好git后,在C:\Users\Administrator\目录下有一个.gitconfig的文件, 里面会有你先前配好的name和email等信息,只需在末尾添加如下内容: [credential] helper = store 下次再输入用户名和密码时,git就会记住, 从而在C:\Users\Administrator\目录下形成一个.git-credentials文件, 里面就是保存的你的用户名和密码(注意是明文存储!!!)。 这样以后再连接时,就不用再输入用户名和密码了! ``` ###**git config基本操作** ``` #配置用户信息 设置了user.name和user.email对工作的产权很重要。 $ git config --global user.name liguodong $ git config --global user.email liguodongiot@163.com $ git config --global user.name liguodong $ git config --global user.email liguodongiot@163.com #git config的三个级别 从高到低依次是local,global,system git config --system git config --global git config --local # 增删改查 $ git config --global --add user.name test #增加 $ git config user.name #查到最新的数据 test $ git config --get user.name #查到最新的数据 test $ git config --list --global user.name=liguodong user.email=liguodongiot@163.com user.name=test $ git config --global --unset user.name test #删除(有多个user.name时) $ git config --global --unset user.name #删除(只有一个user.name时) $ git config --list --global user.name=liguodong user.email=liguodongiot@163.com $ git config --global user.name modifyName #修改 # 给git子命令取别名 $ git config --global alias.co checkout #checkout取别名叫co $ git config --global alias.br branch $ git config --global alias.st status $ git config --global alias.ci commit $ git log #查看日志,按 q 退出 $ git config --global alias.lol "log --oneline" #取别名 $ git lol ``` ###创建仓库以及提交基本操作 > **git init, git clone** > **git add, git commit,git status,git rm,git mv, .gitignore** ``` liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit $ git init git_non_dare_repo Initialized empty Git repository in g:/githubSource/testgit/git_non_dare_repo/.git/ liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit $ cd git_non_dare_repo/.git/ liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_non_dare_repo/.git (GIT_DIR!) $ ls HEAD config description hooks info objects refs ----------- liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit $ git init --bare git_bare_repo Initialized empty Git repository in g:/githubSource/testgit/git_bare_repo/ liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit $ cd git_bare_repo/ liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_bare_repo (BARE:master) $ ls HEAD config description hooks info objects refs ------------ liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit $ mkdir git_init_repo liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit $ cd git_init_repo/ liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_init_repo $ git init Initialized empty Git repository in g:/githubSource/testgit/git_init_repo/.git/ # 克隆远程裸仓库 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit $ git clone git_bare_repo/ git_clone_repo/ Cloning into 'git_clone_repo'... warning: You appear to have cloned an empty repository. done. liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit $ ls git_bare_repo git_clone_repo git_init_repo git_non_dare_repo $ git clone https://github.com/liguodongIOT/Java.git liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit $ git init git_basics Initialized empty Git repository in g:/githubSource/testgit/git_basics/.git/ liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit $ cd git_basics/ liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ touch a liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ touch b liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ git add a b #添加a,b两个文件到暂存区 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: a new file: b liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ git commit -m "Initial commit" #提交到历史记录 [master (root-commit) 224c3bc] Initial commit 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 a create mode 100644 b # 修改了文件a liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ vim a liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ cat a aaa liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: a no changes added to commit (use "git add" and/or "git commit -a") liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ git commit -m "modify a" On branch master Changes not staged for commit: modified: a no changes added to commit # 删除工作区和暂存区的文件 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ git rm -f a rm 'a' liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ ls b liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) deleted: a # 还原 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ git reset HEAD a Unstaged changes after reset: D a liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ ls b liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ git checkout a liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ ls a b # 只删除暂存区的文件 $ git rm --cached a liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_basics (master) $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) deleted: a Untracked files: (use "git add <file>..." to include in what will be committed) a $ git add a #添加回暂存区 # 重命名 git mv a c git status mv c a git status git add a c git status git mv a c <==> mv a c 与 git add a c git add . 与 git add -A 将整个工作区添加到暂存区 # 如果我们不想添加工作区某些文件或者目录 # 可以通过在工作区新建一个.gitignore文件 # 我们可以根据项目的需要通过该文件进行限制。 git add .gitignore git commit -m "add ignore" #添加进仓库用于整个仓库的共享 ``` --- ###git本地分支与合并 > **git branch, git tag, git checkout, git stash, git merge** ``` liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit $ git init git_checkout_merge Initialized empty Git repository in g:/githubSource/testgit/git_checkout_merge/.git/ liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit $ cd git_checkout_merge/ #增加第一次提交 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ vim master.txt liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git add . The file will have its original line endings in your working directory. liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git commit -m "init commit on master" [master (root-commit) 9e797e4] init commit on master warning: CRLF will be replaced by LF in master.txt. The file will have its original line endings in your working directory. 1 file changed, 2 insertions(+) create mode 100644 master.txt #增加第二次提交 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ vim master.txt liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git add . The file will have its original line endings in your working directory. liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git commit -m "second commit on master" The file will have its original line endings in your working directory. 1 file changed, 1 insertion(+) # 当我们有一些其他的工作,不想在master分支直接操作,可以新建一个其他分支进行操作 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git branch test #切换到test分支 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git checkout test Switched to branch 'test' liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (test) $ vim master.txt liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (test) $ touch test.txt liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (test) $ git add . The file will have its original line endings in your working directory. liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (test) $ git commit -m "Init commit on test" The file will have its original line endings in your working directory. 2 files changed, 1 insertion(+) create mode 100644 test.txt # 切换到master分支之后,发现test分支增加的内容,并没有在master分支出现 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (test) $ git checkout master Switched to branch 'master' liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ ls master.txt # 查看历史记录 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git log --oneline --decorate --graph --all * 3bedb7f (test) Init commit on test * 749e699 (HEAD, master) second commit on master * 9e797e4 init commit on master # 对master上的第一个提交做一个轻量级的tag #如果不指定hash值,它默认是当前指向的commit(即head指向的master分支上的commit) liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git tag "v0" 9e797e4 # 创建附注标签 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git tag -a "INITIAL_COMMIT" 9e797e4 # 查看标签 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git tag INITIAL_COMMIT v0 #查看历史示意图 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git log --oneline --decorate --graph --all * 3bedb7f (test) Init commit on test * 749e699 (HEAD, master) second commit on master * 9e797e4 (tag: v0, tag: INITIAL_COMMIT) init commit on master #取别名 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git config --global alias.lol "log --oneline --decorate --graph --all" liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git lol * 3bedb7f (test) Init commit on test * 749e699 (HEAD, master) second commit on master * 9e797e4 (tag: v0, tag: INITIAL_COMMIT) init commit on master ``` ![](image/0005.jpg) ![](image/0006.jpg) ![](image/0007.jpg) ![](image/0008.jpg) ![](image/0009.jpg) ![](image/0010.jpg) ![](image/0011.jpg) ![](image/0012.jpg) ![](image/0013.jpg) ![](image/0014.jpg) ![](image/0015.jpg) ![](image/0016.jpg) ![](image/0017.jpg) ![](image/0018.jpg) ![](image/0019.jpg) ![](image/0020.jpg) ![](image/0021.jpg) --- ### 查看与对比历史记录 > **git show, git log, git diff** ``` liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git log --oneline --decorate --graph --all * d2dfb67 (HEAD, master) Merge branch 'test' |\ | * 3bedb7f (test) Init commit on test * | 13166b8 (test_merge) Init commit on test_merge |/ * 749e699 second commit on master | * d030259 (refs/stash) WIP on fix_v0: 9e797e4 init commit on master | |\ |/ / | * 6f05194 index on fix_v0: 9e797e4 init commit on master |/ * 9e797e4 (tag: v0, tag: INITIAL_COMMIT, fix_v0) init commit on master git show HEAD #等价于git show master 或 git show d2dfb67 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git show master commit d2dfb672e91922024ad27eda83514b1b5adcf54b Merge: 13166b8 3bedb7f Author: liguodong <liguodongiot@163.com> Date: Wed Jan 13 10:19:04 2016 +0800 Merge branch 'test' Conflicts: master.txt diff --cc master.txt index 5babf0f,b331fa2..423afd4 --- a/master.txt +++ b/master.txt @@@ -1,4 -1,4 +1,5 @@@ liguodong hadoop mark flink spark second commit +Init commit on test_merge + init test commit git show master^ #表示master指向的第一父提交 或者 git show master~ git show master^2 #表示master指向的第二父提交 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git show master^2 commit 3bedb7f03ee10156bfc7abfa4099fd7c614e4f67 Author: liguodong <liguodongiot@163.com> Date: Tue Jan 12 19:58:23 2016 +0800 Init commit on test diff --git a/master.txt b/master.txt index d1c2462..b331fa2 100644 --- a/master.txt +++ b/master.txt @@ -1,3 +1,4 @@ liguodong hadoop mark flink spark second commit +init test commit diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..e69de29 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git show --oneline master^2 3bedb7f Init commit on test diff --git a/master.txt b/master.txt index d1c2462..b331fa2 100644 --- a/master.txt +++ b/master.txt @@ -1,3 +1,4 @@ liguodong hadoop mark flink spark second commit +init test commit diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..e69de29 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git show --oneline --stat master^2 3bedb7f Init commit on test master.txt | 1 + test.txt | 0 2 files changed, 1 insertion(+) liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git show --format=%T master^2 c1785ed057fb0bbd7e30bcb9365a4af661869766 diff --git a/master.txt b/master.txt index d1c2462..b331fa2 100644 --- a/master.txt +++ b/master.txt @@ -1,3 +1,4 @@ liguodong hadoop mark flink spark second commit +init test commit diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..e69de29 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git show d1c2462 liguodong hadoop mark flink spark second commit liguodong@WIN-0HGJ9QM2MEG /g/githubSource/testgit/git_checkout_merge (master) $ git show b331fa2 liguodong hadoop mark flink spark second commit init test commit $ git log #显示完整信息 f向上翻页 b向下翻页 q退出 $ git log -p #输出每一个commit之间的差异信息 $ git log --stat #输出每一个commit之间差异的统计信息 $ git log --oneline #输出单行信息 $ git log --oneline --stat -p #输出单行信息的差异 $ git log --oneline --decorate --graph --all $ git diff #工作区与暂存区的差异 ``` ![](image/0023.jpg) ``` $ git diff --cached #查看暂存区与历史的差异 #当前工作区与其他历史文件的差异 $ git diff HEAD~2 -- master.txt #暂存区与历史文件的差异 $ git diff --cached HEAD~2 #两个commit之间的差异 $ git diff HEAD HEAD~2 #可以指定某个文件在两个commit之间的差异 $ git diff HEAD HEAD~2 -- master.txt ``` ![](image/0024.jpg) --- ###撤销与修改操作 > **git checkout, git reset, git clean, git revert** ``` # 当内容被修改,还没有添加进暂存区的时候 git checkout -- master.txt #撤销某个文件修改,实际上是将暂存区覆盖工作区 # 当被修改的文件添加进暂存区,还没有被提交。 git reset master.txt #此时暂存区的内容就会被撤销。 ``` ###git远程协作的主要命令 git clone,git fetch,git pull,git push ``` git clone支持如下几个协议: ssh://[user@]host.xz[:port]/path/to/repo.git/ git://host.xz[:port]/path/to/repo.git/ http[s]://host.xz[:port]/path/to/repo.git/ ftp[s]://host.xz[:port]/path/to/repo.git/ rsync://host.xz/path/to/repo.git/ #克隆远程仓库数据到本地 $ git clone https://github.com/liguodongIOT/Java.git #当远程仓库的数据更新之后,使用git fetch获取远程仓库最新的数据 $ git fetch $ git log -- oneline --decorate --graph --all $ git merge origin/master #将HEAD和master指针移动到最新的commit上面去 $ git lol #查看历史记录 $ git pull #拉取服务器上面的最近数据(相当于git fetch 和 git merge同时操作) #编辑本地文件,并且提交 $ git add test.txt $ git commit -m "test file" $ git push #推送到远程仓库 # 在github上创建远程分支feacher $ git pull #获取最新的信息 From https://github.com/liguodongIOT/Java * [new branch] feacher -> origin/feacher Already up-to-date. $ git pull origin feacher #只更新单独的分支 From https://github.com/liguodongIOT/Java * branch feacher -> FETCH_HEAD Already up-to-date. $ git fetch origin feacher #同样可以使用fetch $ git checkout v0 #先切换到v0分支 $ git push origin master #再单独提交master分支 # 在本地删除feature分支 $ git branch -d feacher # 删除远程分支 $ git push -delete origin feacher #方式一 $ git push origin :feacher #方式二 以一个空的分支替代远程仓库的feacher分支 ``` ###git tag打标签 标签可以针对某一时间点的版本做标记,常用于版本发布。 ``` # 列出标签 $ git tag # 在控制台打印出当前仓库的所有标签 $ git tag -l 'v0.1.*' # 搜索符合模式的标签 # 打标签 git标签分为两种类型:轻量标签和附注标签。 轻量标签是指向提交对象的引用, 附注标签则是仓库中的一个独立对象。建议使用附注标签。 # 创建轻量标签 $ git tag v0.1.2-light # 创建附注标签 $ git tag -a v0.1.3 -m "tag for v0" 创建轻量标签不需要传递参数,直接指定标签名称即可。 创建附注标签时,参数a即annotated的缩写,指定标签类型, 后附标签名。参数m指定标签说明,说明信息会保存在标签对象中。 # 删除标签 误打或需要修改标签时,需要先将标签删除,再打新标签。 $ git tag -d v0.1.2 # 删除标签 参数d即delete的缩写,意为删除其后指定的标签。 # 给指定的commit打标签,打标签不必要在head之上, # 也可在之前的版本上打,这需要你知道某个提交对象的 # 校验和(通过git log获取)。 # 补打标签 $ git tag -a v0.1.1 9fbc3d0 # 标签发布 # 通常的git push不会将标签对象提交到git服务器, # 我们需要进行显式的操作: $ git push origin v0.1.2 # 将v0.1.2标签提交到git服务器 $ git push origin –tags # 将本地所有标签一次性提交到git服务器 ``` ``` liguodong@WIN-0HGJ9QM2MEG /g/githubSource $ git clone https://github.com/liguodongIOT/GitHubStudyTest.git Cloning into 'GitHubStudyTest'... remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. Checking connectivity... done. liguodong@WIN-0HGJ9QM2MEG /g/githubSource $ cd GitHubStudyTest/ liguodong@WIN-0HGJ9QM2MEG /g/githubSource/GitHubStudyTest (master) $ git checkout -b feacher #切换分支 Switched to a new branch 'feacher' liguodong@WIN-0HGJ9QM2MEG /g/githubSource/GitHubStudyTest (feacher) $ vim Demo.txt liguodong@WIN-0HGJ9QM2MEG /g/githubSource/GitHubStudyTest (feacher) $ cat Demo.txt This is a GitHub test... liguodong@WIN-0HGJ9QM2MEG /g/githubSource/GitHubStudyTest (feacher) $ git add Demo.txt The file will have its original line endings in your working directory. liguodong@WIN-0HGJ9QM2MEG /g/githubSource/GitHubStudyTest (feacher) $ git commit -m "add some feacher" [feacher 187b8a1] add some feacher The file will have its original line endings in your working directory. 1 file changed, 1 insertion(+) create mode 100644 Demo.txt liguodong@WIN-0HGJ9QM2MEG /g/githubSource/GitHubStudyTest (feacher) $ git push origin feacher #将feacher分支推送到GitHubStudyTest项目下 Counting objects: 4, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 297 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To https://github.com/liguodongIOT/GitHubStudyTest.git 7faaf33..187b8a1 feacher -> feacher ``` ``` #查看git版本,可以通过设置环境变量保证系统优先使用我们希望使用的git版本 $ git --version git version 1.9.5.msysgit.1 ``` ``` #新的项目 liguodong@WIN-0HGJ9QM2MEG /g/github $ git init projectExample Initialized empty Git repository in g:/github/projectExample/.git/ liguodong@WIN-0HGJ9QM2MEG /g/github/projectExample (master) $ pwd /g/github/projectExample liguodong@WIN-0HGJ9QM2MEG /g/github/projectExample (master) $ ls -al .git total 4 drwxr-xr-x 9 liguodon Administ 4096 Jan 10 22:08 . drwxr-xr-x 3 liguodon Administ 0 Jan 10 22:08 .. -rw-r--r-- 1 liguodon Administ 23 Jan 10 22:08 HEAD -rw-r--r-- 1 liguodon Administ 157 Jan 10 22:08 config -rw-r--r-- 1 liguodon Administ 73 Jan 10 22:08 description drwxr-xr-x 11 liguodon Administ 0 Jan 10 22:08 hooks drwxr-xr-x 3 liguodon Administ 0 Jan 10 22:08 info drwxr-xr-x 4 liguodon Administ 0 Jan 10 22:08 objects drwxr-xr-x 4 liguodon Administ 0 Jan 10 22:08 refs #当需要与别人分享时 liguodong@WIN-0HGJ9QM2MEG /g/github/projectExample (master) $ git remote add origin https://github.com/liguodongwork/projectExample liguodong@WIN-0HGJ9QM2MEG /g/github/projectExample (master) $ cat .git/config [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true hideDotFiles = dotGitOnly [remote "origin"] url = https://github.com/liguodongwork/projectExample fetch = +refs/heads/*:refs/remotes/origin/* #设置行尾,以满足不同操作系统 liguodong@WIN-0HGJ9QM2MEG /g/githubSource/liguodongiot.github.io (master) $ git config --global core.autocrlf true #Windows $ git config --global core.autocrlf input #Linux,Mac 如果你是Windows程序员,且正在开发仅运行在Windows上的项目,可以设置`false`取消此功能,把回车符记录在库中: $ git config --global core.autocrlf false #设置高亮配置 git config --global color.ui true git config --global color.ui always git remote set-url origin https://github.com/liguodongIOT/liguodongiot.github.io.git ```