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環境)git

eval `ssh-agent -s`
ssh-add.exe github_rsa
# 編輯器設置爲EmEditor
git config core.editor "'EmEditor.exe' //sp"

以上方法沒有根本性解決問題github

# 若是你在新建祕鑰的時候使用了自定義的名稱,好比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
相關文章
相關標籤/搜索