Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
楼主: java
打印 上一主题 下一主题

git命令行操作

[复制链接]

1228

主题

1997

帖子

7582

积分

认证用户组

Rank: 5Rank: 5

积分
7582
楼主
发表于 2017-3-3 09:02:30 | 显示全部楼层
本帖最后由 Qter 于 2023-3-14 14:16 编辑

1、在PowerShell中输入以下命令
git config --global core.quotepath false
git config --global gui.encoding utf-8
git config --global i18n.commit.encoding utf-8
git config --global i18n.logoutputencoding utf-8
$envESSCHARSET='utf-8'
2、在系统环境变量中添加变量 LESSCHARSET 为 utf-8 .

查看设置的变量
git config --global -l

git config --global --get core.quotepath
git config --global --get gui.encoding
git config --global --get i18n.commit.encoding
git config --global --get i18n.logoutputencoding

取消对变量的设置
git config --global --unset gui.encoding



Permission denied (publickey).
fatal: The remote end hung up unexpectedly.

Permission denied (publickey).
fatal: Could not read from remote repository.


换个目录 ,原来是把代码放到了 /usr/local下
改为/home/xxxx/xx下就可以 了



git fetch --prune
        https://git-scm.com/docs/git-fetch
        Before fetching, remove any remote-tracking references that no longer exist on the remote
        同git remote prune
        删除本地分支        
        git branch -d/D dev  -D 强制删除


修改日志格式:
git log --date=iso                 ---当前查看 一次有效

git config --global log.date iso  ---全局生效





----------------------------------------
从本地.git中还原代码
git reset –hard (commit版本hash码)



-------------------


λ git pull
warning: Pulling without specifying how to reconcile divergent branches is
discouraged. You can squelch this message by running one of the following
commands sometime before your next pull:


  git config pull.rebase false  # merge (the default strategy)
  git config pull.rebase true   # rebase
  git config pull.ff only       # fast-forward only


You can replace "git config" with "git config --global" to set a default
preference for all repositories. You can also pass --rebase, --no-rebase,
or --ff-only on the command line to override the configured default per
invocation.


Already up to date.








λ git config --global
usage: git config [<options>]


Config file location
    --global              use global config file
    --system              use system config file
    --local               use repository config file
    --worktree            use per-worktree config file
    -f, --file <file>     use given config file
    --blob <blob-id>      read config from given blob object


Action
    --get                 get value: name [value-regex]
    --get-all             get all values: key [value-regex]
    --get-regexp          get values for regexp: name-regex [value-regex]
    --get-urlmatch        get value specific for the URL: section[.var] URL
    --replace-all         replace all matching variables: name value [value_regex]
    --add                 add a new variable: name value
    --unset               remove a variable: name [value-regex]
    --unset-all           remove all matches: name [value-regex]
    --rename-section      rename section: old-name new-name
    --remove-section      remove a section: name
    -l, --list            list all
    -e, --edit            open an editor
    --get-color           find the color configured: slot [default]
    --get-colorbool       find the color setting: slot [stdout-is-tty]


Type
    -t, --type <>         value is given this type
    --bool                value is "true" or "false"
    --int                 value is decimal number
    --bool-or-int         value is --bool or --int
    --path                value is a path (file or directory name)
    --expiry-date         value is an expiry date


Other
    -z, --null            terminate values with NUL byte
    --name-only           show variable names only
    --includes            respect include directives on lookup
    --show-origin         show origin of config (file, standard input, blob, command line)
    --show-scope          show scope of config (worktree, local, global, system, command)
    --default <value>     with --get, use default value when missing entry










之前克隆到本地的项目,用这个命令切换即可,不需要重新克隆:
git remote set-url origin 新地址
如:git remote set-url origin https://192.168.8.7/tt/tt.git







回复 支持 反对

使用道具 举报

1228

主题

1997

帖子

7582

积分

认证用户组

Rank: 5Rank: 5

积分
7582
沙发
发表于 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

主题

1997

帖子

7582

积分

认证用户组

Rank: 5Rank: 5

积分
7582
板凳
发表于 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

主题

1997

帖子

7582

积分

认证用户组

Rank: 5Rank: 5

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

使用道具 举报

1228

主题

1997

帖子

7582

积分

认证用户组

Rank: 5Rank: 5

积分
7582
5#
发表于 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-5-5 23:33 , Processed in 0.066392 second(s), 20 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

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