git --- configuration (continuously updated ~)

The –global parameter of the git config command uses this parameter to indicate that all Git warehouses on your machine will use this configuration. Of course, you can also specify a different user name and email address for a certain warehouse.

View git configuration information

git config --list

User information used when configuring git commit

Check the configuration of git username, password and email

git config user.name
git config user.password
git config user.email

Set the configuration of git username, password and email address (global)

git config --global user.name "XXX"
git config --global user.password "XXX"
git config --global user.email "[email protected]"

Edit and modify configuration files (global modification, deletion)

method one:

git config --global user.name "freedom"   # 跟设置语法一样,没有用户名就添加,有了用户名就修改

Method Two:

git config --global --edit     
i                            # 进入编辑模式        
按【esc】退出编辑              # 退出编辑
:wq                         # 保存

Method three:

open .                       # 在终端~
shift+cmmand+.               # 显示前面带有小点的隐藏文件
找到并打开.gitconfig文件,进行编辑

User information used when configuring git push

View current account

cat ~/.git-credentials

View the password saved by the system in MAC (password certificate)

  1. First find the icon of "Keychain Access" on the computer system interface, open it

img

  1. Search to find gitlab
    insert image description here

  2. Double-click to open the properties, modify [account] and [s password] to the gitlab account password that needs to be bound

Note: To modify the password, first select [Show Password]
insert image description here

Set git command shortcut keys (global)

Open ~/.oh-my-zsh/plugins/git/git.plugin.zsh, find a bunch of aliases, and list a few commonly used ones

alias ga='git add'
alias gcm='git commit -m'
alias gcam='git commit -a -m'
alias gl='git pull'
alias gp='git push'
alias gco='git checkout'
alias gm='git merge'
alias gs='git stash'
alias gsp='git stash pop'
alias gf='git fetch'
alias gb='git branch'
alias grh='git reset'

git change warehouse address

remote operation

Create a new warehouse on github and get the address of the new warehouse

img
insert image description here

insert image description here

local operation

git remote -v  # 查看当前绑定的远程仓库(缩写:grv )

!

Method 1: Delete the original warehouse and bind the new warehouse

git remote remove origin # 删掉原来git新仓库(源)
git remote add origin XXXXXX.git   # 将新仓库(源)地址写入本地版本库配置文件
git branch -M main # 创建新分支
git push -u origin main # 提交所有代码

insert image description here

Method 2: Add a new warehouse without deleting the original warehouse

git remote add lcy XXXX.git   # 将新仓库(源)地址写入本地版本库配置文件(lcy为新增新仓库(源)名)
git branch -M main # 创建新分支
git push -u lcy main # 将main分支推到指定远端仓库(lcy为目标远端仓库)
git pull --rebase origin master # 从名为origin的仓库(源)master分支的拉取代码

------------- Continuously updating-------------

License Agreement: For reprinting, please keep the original link and author.

Guess you like

Origin blog.csdn.net/weixin_43937466/article/details/121554877