Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
12
返回列表 发新帖
楼主: java
打印 上一主题 下一主题

git命令行操作

[复制链接]

697

主题

1142

帖子

4086

积分

认证用户组

Rank: 5Rank: 5

积分
4086
11#
 楼主| 发表于 2017-8-17 18:17:26 | 只看该作者
本帖最后由 java 于 2017-11-23 16:16 编辑

missing change-id


git commit -a --amend -s

查看某条日志的具体修改内容
git show cdb90e69217a7ac65bc6e52e2622066a05aa10cf

用git show <commit-hashId> 便可以显示某次提交的修改内容
同样 git show <commit-hashId> filename 可以显示某次提交的某个内容的修改信息。

查看某一文件的历史性改动

git log --pretty=oneline 文件名

查看某一目录的修改日志
git log --pretty=format:'%h was %an, %ar, message: %s' srcdir

修改git log默认的时间显示方式
git config log.date iso  临时git config log.date iso  --global


查看配置信息
npm config ls -l

设置代理
npm config set proxy http://proxyhostname:proxyport
npm config set https-proxy http://proxyhostname:proxyportnpm的代理设置

git config --global http.proxy "localhost:1080"
git config --global https.proxy http://proxy.com:1234
git config --global https.proxy https://127.0.0.1:8580

移除代理
npm config rm proxy
npm config rm https-proxy
>npm config set proxy null
>npm config set https-proxy null

npm config set proxy false
npm cache clean

--global~/.gitconfig
--system
$(prefix)/etc/gitconfig
--local
.git/config


//config
git config --global -l
git config --global --list

git config --global --unset http.sslverify


git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'

如果清理完了,还是连接原来的端口,则是下面shell脚本设置了环境变量
  1. export http_proxy=http://127.0.0.1:8787
  2. export https_proxy=$http_proxy
  3. git config --global http.proxy $http_proxy
  4. git config --global https.proxy $https_proxy
复制代码

/etc/profile
~/.bashrc       lantern会写到其它文件,直接在这重新定义  export http_proxy=‘’
~/.profile

日志统计
git shortlog -sn  按照提交的commit数量进行统计
git shortlog -sn --since="7 weeks" --until="1 weeks"  对某一个时间段进行统计










查看指定用户的git提交记录git log --author=username
username为指定的用户



回复 支持 反对

使用道具 举报

697

主题

1142

帖子

4086

积分

认证用户组

Rank: 5Rank: 5

积分
4086
12#
 楼主| 发表于 2017-8-17 18:25:27 | 只看该作者
本帖最后由 java 于 2018-9-29 14:31 编辑

查看远程分支
git branch -a

查看本地分支
git branch

创建分支
git branch test

切换分支到test
git checkout test


删除本地分支
git branch -d test

删除远程分支
命令行 : $ git push origin --delete <BranchName>


查看clone的源码路径
git remote -v




git remote -av

git branch -av
回复 支持 反对

使用道具 举报

697

主题

1142

帖子

4086

积分

认证用户组

Rank: 5Rank: 5

积分
4086
13#
 楼主| 发表于 2017-9-20 16:40:25 | 只看该作者
本帖最后由 java 于 2017-11-30 16:10 编辑

Linux下以https(用户名密码)方式同步代码
git clone https://github.com/xxx/shell.git
...
git commit
git push -u origin master


http://www.111cn.net/sys/linux/79505.htm



git reset --hard ecd265ac831681c035479d69948313ebf3a4c736  //不保留改动过的内容


git reset 215b364ca8b6f8134230dfba38446594fbb31555   //保存改动过的内容

回复 支持 反对

使用道具 举报

1228

主题

1996

帖子

7570

积分

认证用户组

Rank: 5Rank: 5

积分
7570
14#
发表于 2021-3-8 15:33:38 | 只看该作者
[backcolor=var(--color-box-header-blue-bg)]Quick setup — if you’ve done this kind of thing before[color=var(--color-btn-text)][backcolor=var(--color-btn-bg)] Set up in Desktop
or
HTTPSSSH




Get started by [color=var(--color-text-link)]creating a new file or [color=var(--color-text-link)]uploading an existing file. We recommend every repository include a [color=var(--color-text-link)]README, [color=var(--color-text-link)]LICENSE, and [color=var(--color-text-link)].gitignore.

…or create a new repository on the command line[backcolor=var(--color-bg-tertiary)]
echo "# MyNotebook" >> README.mdgit initgit add README.mdgit commit -m "first commit"git branch -M maingit remote add origin git@github.com:hechengjin/MyNotebook.gitgit push -u origin main

…or push an existing repository from the command line[backcolor=var(--color-bg-tertiary)]
git remote add origin git@github.com:hechengjin/MyNotebook.gitgit branch -M maingit push -u origin main

…or import code from another repository
You can initialize this repository with code from a Subversion, Mercurial, or TFS project.
[color=var(--color-btn-text)][backcolor=var(--color-btn-bg)]Import code




回复 支持 反对

使用道具 举报

1228

主题

1996

帖子

7570

积分

认证用户组

Rank: 5Rank: 5

积分
7570
15#
发表于 2021-12-1 14:00:11 | 只看该作者
重命名git tag
1. git tag newtag oldtag

2. git tag -d oldtag


3. git push origin :refs/tags/oldtag


4. git push --tags


回复 支持 反对

使用道具 举报

1228

主题

1996

帖子

7570

积分

认证用户组

Rank: 5Rank: 5

积分
7570
16#
发表于 2022-10-26 19:17:47 | 只看该作者
如果觉得一遍遍地输入密码很烦,可以按照这个页面 提供的方案来把密码保存起来。
另外还有一个更简单但安全性低一些的方案。执行这行代码:
git config credential.helper store
在这之后你只需要再输入一次密码, Git 就会把你的密码保存下来,这之后就再也不用输入了。说它「安全性低」,是因为这条指令会让 Git 把你的密码以明文形式保存在你的电脑上。具体这两种保存密码的方案选择哪个,看你自己了。
回复 支持 反对

使用道具 举报

1228

主题

1996

帖子

7570

积分

认证用户组

Rank: 5Rank: 5

积分
7570
17#
发表于 2022-10-27 10:03:04 | 只看该作者
本帖最后由 Qter 于 2022-10-27 10:09 编辑

功能分支合并到主分支并删除功能分支

git checkout master

git pull # merge 之前 pull 一下,让 master 更新到和远程仓库同步


git merge feature1




git push


git branch -d feature1


git push origin -d feature1# 用 -d 参数把远程仓库的 branch 也删了






推送到远程分支
git checkout feature1git push origin feature1

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|firemail ( 粤ICP备15085507号-1 )

GMT+8, 2024-4-20 07:50 , Processed in 0.064401 second(s), 19 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表