6.4-Git Command

git指令-Basic

前言

  • 废话,必学

记录

git 设置gedit为编辑器

git config --global core.editor "gedit -s"

Linux 初始化

ssh-keygen -t rsa -C "lzs_1993@qq.com" -f ~/.ssh/github
gedit ~/.ssh/github.pub
ssh-add ~/.ssh/github
ssh -T git@github.com
yes
创建一个仓库
在网页版中创建
git config --global user.email lzs_1993@qq.com
git config --global user.name "Victor Lee"
git config --global core.editor "code -n "
git config --global core.editor "subl -n -w"
git config --list
git status -s
git diff
git clone git@github.com:zhenshengLee/zsROS.git
git add .
git reset HEAD <file>
git commit  -m "first adding files"
git commit -a -m "add some reference files"
git add <missing add file>
git commit --amend
git push git@github.com:zhenshengLee/zsROS.git
cd ./zsROS
git pull git@github.com:zhenshengLee/zsROS.git
update the native file
git fetch zsROS
git merge
git rm
git rm --cached
git log
git checkout -- CONTRIBUTING.md
git remote add pb https://github.com/paulboone/ticgit
git push [remote-name] [branchname]
git push origin master
git remote show origin
git remote rename pb paul
git tag
Git Command - Branch
git branch testing
git checkout testing
git checkout -b iss53
git branch iss53
git checkout iss53
git commit --amend
git checkout master
git merge hotfix
git branch -d hotfix
git branch --merged
git branch -d xxx
git branch --no-merged
git push origin --delete serverfix
git checkout experiment
git rebase master
git fetch git@github.com:zhenshengLee/zsROS.git

Git LabVIEW设置

git config --global core.editor "code "
ssh -T git@github.com
mkdir -p /usr/local
git clone -b windows git://github.com/joerg/LabViewGitEnv.git /usr/local/
cd /usr/local && git checkout -b local
LVInit.sh --global
# Example usage
### Assume you have a master branch with a few commits and a feature branch with new changes. You currently have master checked out.
## diff
### To diff those branches, you can use git diff feature which will bring up LVCompare.exe with the correct attributes and show you the differences between master and feature.
## merge
### To merge those branches, you can use git merge feature
### which will bring up LVMerge.exe. This will show you 4 different versions:
### Base, which is the common ancestor of feature and master,
### Theirs which is the vi in feature,
### Yours, which is the vi in master,
### and finally the merged vi.
### Just edit the merged vi if necessary, save it and press close, and GIT will automagically create a nice merge commit.
## Attention
### When calling git merge feature master GIT will not call LVMerge.exe at first, but will try to do an internal merge which will fail. You will then have to use git mergetool -t labview to call LVMerge.exe and do the merge.

Git Windows 设置

如果出现PublicKey错误,尝试以下操作(MimGW环境)

eval `ssh-agent -s`
ssh-add.exe github_rsa
# 编辑器设置为EmEditor
git config core.editor "'EmEditor.exe' //sp"

以上方法没有根本性解决问题

# 如果你在新建秘钥的时候使用了自定义的名称,比如github_rsa,你需要再配置一个config文件
cd ~/.ssh/
vi config

Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/github_rsa
# 网页创建一个仓库
cd GitHub
git clone git@github.com:zhenshengLee/zsLV.git
git fetch
git add .
git commit  -m "first adding files"
git commit -a -m "add some reference files"
git commit --amend
git push git@github.com:zhenshengLee/zsLV.git
git merge
# 创建一个分支
git branch change_joystick
git checkout change_joystick
git checkout -b change_joystick
git checkout master
git merge change_joystick
git push origin change_joystick
git branch -d hotfix
git push origin --delete change_joystick
git branch --merged
git branch -d xxx
# 提交文件
git pull
git push
# 查看分支
git branch
# 删除分支
git push origin :unit_test //删除远程分支
git branch -d hotfix//删除本地分支
# 撤销
git reset HEAD <file>
git checkout -- [file]

本地没有该分支时拉取远程分支

git branch -a
git checkout -b link-rosforlv origin/link-rosforlv
git checkout -t origin/link-rosforlv

某分支从主分支拉取最新更新

撤销所有修改

git checkout .

sourcetree-bitbucket

ssh-keygen
# 回车即可
# 打开/c/Users/Administrator/.ssh/id_rsa.pub
# 添加到bitbucket
# sourcetree 工具-选项-一般-ssh-openssh
  • 对于一个已有的项目
git remote add origin ssh://git@bitbucket.org/zhenshengli/zslv.git
git push -u origin master
git checkout ...
git push
ssh -T git@bitbucket.org

Linux-bitbucket

ssh-keygen -C "lzs_1993@qq.com" -f ~/.ssh/bitbucket
gedit ./.ssh/bitbucket.pub
ssh -T git@bitbucket.org
yes

VSCode出现

  • Run Git Bash, cd to repo dir and enter git config --global credential.helper wincred
posted @ 2019-07-01 22:26  哈骑士  阅读(313)  评论(0编辑  收藏  举报