Git Notes

Git Notes

git 源码安装

1
//依赖库 gcc gcc-c++

git proxy

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
//http || https
git config --global http.proxy 127.0.0.1:2080
git config --global https.proxy 127.0.0.1:2080

//sock5代理
git config --global http.proxy socks5 127.0.0.1:2080
git config --global https.proxy socks5 127.0.0.1:2080

git config --global --get http.proxy
git config --global --get https.proxy

git config --global --unset http.proxy
git config --global --unset https.proxy

git log

  • -p 显示diff补丁 -2 限定数量
  • --stat 显示简略统计信息
  • --pretty =oneline一行输出 =short,full,fuller
    1
    2
    3
    4
    
    $ git log --pretty=format:"%h - %an, %ar : %s"
      ca82a6d - Scott Chacon, 6 years ago : changed the version number
      085bb3b - Scott Chacon, 6 years ago : removed unnecessary test
      a11bef0 - Scott Chacon, 6 years ago : first commit
    

git commit --amend


git commit -a -m "msg"

提交所有跟踪的文件(不包括新建的),省去了add

git reset HEAD <file>

取消暂存


git checkout -- <file>

用最近提交的版本覆盖现在的文件

分支

git branch <branchname>

创建分支,HEAD指针为当前分支的别名

git checkout <branchname>

切换分支

git checkout -a <branchname>

自动创建并切换到该分支

git merge <branchname>

如果合并分支是顺序推进,则会指向一个较新的版本

git merge <branchname>

寻找共同的祖先快照,git自动合并分支,如果发生冲突见下

<merge conflict>

git status

查看包含冲突而为合并(unmerged)的文件

1
2
3
4
$ git merge iss53
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
1
2
3
4
5
6
7
8
$ git status
On branch master
You have unmerged paths.
  (fix conflicts and run "git commit")
Unmerged paths:
  (use "git add <file>..." to mark resolution)
  both modified: index.html
no changes added to commit (use "git add" and/or "git commit -a")

it looks like

1
2
3
4
5
6
7
<<<<<<< HEAD:index.html
<div id="footer">contact : email.support@github.com</div>
=======
<div id="footer">
 please contact us at support@github.com
</div>
>>>>>>> iss53:index.html

在你解决了所有文件里的冲突之后,对每个文件使用 git add 命令来将其标记为冲突已解决。 一旦暂存这 些原本有冲突的文件,Git 就会将它们标记为冲突已解决。


git branch (-v)

得到所有分支的列表,or查看每个分支的最后一个提交

git branch --merged (<branchname>)

查看哪些分支已经合并到当前分支,在这个列表中分支名字前没有 * 号的分支通常可以使用 git branch -d 删除掉;你已经将它们的工作整合到了另一个分支,所以并不会失去任何东西。

git branch --no-merged (<branchname>)

这里显示了其他分支。 因为它包含了还未合并的工作,尝试使用 git branch -d 命令删除它时会失败:

1
2
3
$ git branch -d testing
error: The branch 'testing' is not fully merged.
If you are sure you want to delete it, run 'git branch -D testing'.

Git 编译安装

wget [url]

tar -xzvf *.tar.gz

x extract 解压

z gzip格式

v 显示执行过程

f 指定文件名,相当于执行后重命名

安装依赖项

1
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

配置安装路径

1
2
3
./configure prefix=/usr/local/git/

make && make install

添加PATH到bash

1
2
3
4
5
6
7
vi /etc/profile

export PATH=$PATH:/usr/local/git/bin

source /etc/profile

git --version
Licensed under CC BY-NC-SA 4.0
最后更新于 Aug 14, 2024 09:45 UTC