Git basic
Git some notes
1. git存储方式
按照元数据内部存储类似k/v存储
基本使用
几种创建分支
基于当前分支新建分支
git branch
基于提交新建分支
git branch
基于tag新建分支
git branch
其他待实际操作发现
一些问题
git commit -a
和git add .
区别git commit -a
means almost[*] the same thing asgit add -u && git commit
.It's not the same as
git add .
as this would add untracked files that aren't being ignored,git add -u
only stages changes (including deletions) to already tracked files.[] There's a subtle difference if you're not at the root directory of your repository.
git add -u
stages updates to files in the current directory and below, it's equivalent togit add -u .
whereasgit commit -a
stages and commits changes to all* tracked files.source:区别
git add -A
andgit add .
andgit add -u
区别According to git version 1.x
“git add -A” is equivalent to “git add .” and “git add -u“
git add -A stages All
git add . stages new and modified, without deleted
git add -u stages modified and deleted, without new
The important point about git add . is that it looks at the working tree and adds all those paths to the staged changes if they are either changed or are new and not ignored, it does not stage any ‘rm’ actions.
git add -u looks at all the already tracked files and stages the changes to those files if they are different or if they have been removed. It does not add any new files, it only stages changes to already tracked files.
git add -A is a handy shortcut for doing both.
git add -A is equivalent to git add –all
git add -u is equivalent to git add –update
According to git version 2.x
git add -A stages All
git add . stages All in same path
git add -u stages modified and deleted, without new
There is no more difference in 2.0. git add . equals to git add -A for the same path, the only difference is if there are new files in other paths of the tree.
With Git 2.0, git add -A is default: git add . equals git add -A .
Source:[differences](https://www.dineshonjava.com/difference-between-git-add-a-and-git-add-dot-and-git-u/#:~:text=git%20add%20%2Du%20looks%20at,handy%20shortcut%20for%20doing%20both.)
git 如何处理Symlink file,如何处理链接的文件?
只是记录追踪了合格链接文件,并未追踪这个链接引用的文件
So, that's what Git does to a symbolic link: when you git checkout the symbolic link, you either get a text file with a reference to a full filesystem path, or a symlink, depending on configuration. The data referenced by the symlink is not stored in the repository.
建议写成相对路径添加e.g.
ln -s ../xxx.md xxx.md
The reason for this is that given that a symlink contains the path to the referenced file, if the path is relative to a specific machine the link won't work on others. If it's relative to the repository itself on the other hand, the OS will always be able to find the source.
:Way to my success!
Last updated