ubuntu16.04 git的配置
git的命令
usage: git [--version] [--help] [-C <path>] [-c name=value]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status
grow, mark and tweak your common history
branch List, create, or delete branches
checkout Switch branches or restore working tree files
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
merge Join two or more development histories together
rebase Forward-port local commits to the updated upstream head
tag Create, list, delete or verify a tag object signed with GPG
collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
ubuntu16.04 git 卸載
apt-get remove git
git 的安裝及配置
- 安裝git,在終端輸入,雙引號填寫你自己的用戶名
git config --global user.name "your name"
- 配置git,在終端輸入
git config --global user.email "your email
- 創建公鑰,寫上自己的email
ssh-keygen -C "your email" -t rsa
4.在github添加SSH key。
將目錄下的.ssh/id_rsa.pub裏的內容全部複製。登錄github網站,在settings裏選擇SSH and GPG keys
在title中爲本次添加的key取一個名字,將前面粘貼的內容複製到下面的框中。
點擊Add SSH key。
- 將key加入到ssh-agent,在終端輸入
ssh-add ~/.ssh/id_rsa
- 測試根據自己的需求測試網站可以是碼雲的,也可以是github的,我這裏配置的是碼運。
ssh -T [email protected]
或則
ssh -T [email protected]
輸入以下內容就表示設置成功了。
-
進行本地向gitee(碼雲)上傳代碼,大致命名如下:
git init git add . git commit -m "first commit" git remote add origin [email protected]:b/T.git git pull origin master
test@hello:~/test/repos$ cd test/ test@hello:~/test/repos/test$ ls origin_ctg test@hello:~/test/repos/test$ git init Initialized empty Git repository in /home/yeee/test/repos/test/.git/ test@hello:~/test/repos/test$ git add origin_ctg/ test@hello:~/test/repos/test$ git commit -m "first commit" [master (root-commit) e12b13c] first commit 5 files changed, 280 insertions(+) create mode 100644 origin_ctg/.idea/modules.xml create mode 100644 origin_ctg/.idea/origin_ctg.iml create mode 100644 origin_ctg/.idea/vcs.xml create mode 100644 origin_ctg/.idea/workspace.xml create mode 160000 origin_ctg/MCTG test@hello:~/test/repos/test$ git remote add origin [email protected]:b/T.git test@hello:~/test/repos/test$ git pull origin master warning: no common commits remote: Enumerating objects: 4, done. remote: Counting objects: 100% (4/4), done. remote: Compressing objects: 100% (4/4), done. remote: Total 4 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (4/4), done. From gitee.com:yeee/test * branch master -> FETCH_HEAD * [new branch] master -> origin/master Merge made by the 'recursive' strategy. README.en.md | 36 ++++++++++++++++++++++++++++++++++++ README.md | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 README.en.md create mode 100644 README.md test@hello:~/test/repos/test$ git push origin master Counting objects: 10, done. Delta compression using up to 48 threads. Compressing objects: 100% (9/9), done. Writing objects: 100% (10/10), 3.87 KiB | 0 bytes/s, done. Total 10 (delta 0), reused 0 (delta 0) remote: Powered By Gitee.com To [email protected]:yeee/test.git 839e8ea..ad9975b master -> master
遇到問題
執行 git pull origin master
跳出了Nano編輯器如下圖:解決方案是這個是使用nano進行編輯提交的頁面,退出方法爲:
Ctrl + X然後輸入y再然後回車,就可以退出了
如果你想把默認編輯器換成別的:
方法一、在GIT配置中設置
core.editor: git config --global core.editor "vim"
方法二、編輯~/.gitconfig文件。在core中添加editor = vim。如此以後在使用git的時候就自動使用vim作爲編輯器