1. 新建project
The repository for this project is emptyIf you already have files you can push them using command line instructions below.Otherwise you can start with adding a README, a LICENSE, or a .gitignore to this project.
Command line instructions
Git global setupgit config –global user.name “Administrator”
git config –global user.email “admin@example.com”Create a new repositorygit clone cd yaobin_test
touch README.md
git add README.md
git commit -m “add README”
git push -u origin masterExisting folder or Git repositorycd existing_folder
git init
git remote add origin git add .
git commitgit commit
git push -u origin master
2. 增加key
①增加172.18.7.79 机器的key
[root@action_test ~/.ssh]# ssh-keygen -C "chenyaobin"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
4d:c7:63:aa:27:e9:5c:2c:3c:5d:b7:d0:6a:86:8c:15 chenyaobin
The key's randomart image is:
+--[ RSA 2048]----+
| |
| . |
| E = |
| o = o |
| S + o o |
| . O o + . |
| O B + . |
| o * o |
| o |
+-----------------+
[root@action_test ~/.ssh]# cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA62MGMDF6w7PawPORPocJBqPy58rjtcvkyTVC9FoBetbU5VDpaEpKgnfl8TZOO7bUr4CVKuaGEQdS8Xo5kkomlfrxbyyUV0CCd/WtKROPOO8wyIBOY1HdvPeTa+N/pgcw9QnAZbMTIFCXlzPYIamtKQvWgwpVC/tJPalQL4RFJyKDEGf5fLdxAUz1nqmScqfuCsM/cJ8tiHja90sPhwyBGrDwt0znPtcU9Jz9symxemE+IEF3fdge5rP/TvzJdEQX8HZPT8Zf4cI29GnWtNB+OV6MM5FtJUjBtHSqvxcLnNxbatWrGDYXI1y35ST43FIKToR29XJGJW1fE3Pa2z2Pdw== chenyaobin
- 在gitlab上增加key
- 尝试clone:
[root@action_test /shell]# git clone git@slave2:root/yaobin_test.git
Initialized empty Git repository in /shell/yaobin_test/.git/
warning: You appear to have cloned an empty repository.
② 增加我自己pc机器的key
首先查看自己pc机器的pub key
在gitlab上增加自己机器的key
自己写host slave2后,尝试clone
- 成功!!
3. 初始化yaobin_test 项目
[root@action_test /shell/yaobin_test]# ls
README.md
[root@action_test /shell/yaobin_test]# mkdir a b c
[root@action_test /shell/yaobin_test]# ls
a b c README.md
[root@action_test /shell/yaobin_test]# touch ^C
[root@action_test /shell/yaobin_test]# cd a
[root@action_test /shell/yaobin_test/a]# ls
[root@action_test /shell/yaobin_test/a]# echo aaaaaaaa> 1
[root@action_test /shell/yaobin_test/a]# ls
1
[root@action_test /shell/yaobin_test/a]# cd ../
[root@action_test /shell/yaobin_test]# ls
a b c README.md
[root@action_test /shell/yaobin_test]# cd b/
[root@action_test /shell/yaobin_test/b]# ls
[root@action_test /shell/yaobin_test/b]# echo bbbbbbbbbbbb>2
[root@action_test /shell/yaobin_test/b]# ls
2
[root@action_test /shell/yaobin_test/b]# cd ../c
[root@action_test /shell/yaobin_test/c]# ls
[root@action_test /shell/yaobin_test/c]# echo ccccccccccccc>3
[root@action_test /shell/yaobin_test/c]# ls
3
[root@action_test /shell/yaobin_test/c]# cd ../
[root@action_test /shell/yaobin_test]# ls
a b c README.md
[root@action_test /shell/yaobin_test]# git add ./
[root@action_test /shell/yaobin_test]# ls
a b c README.md
[root@action_test /shell/yaobin_test]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: README.md
# new file: a/1
# new file: b/2
# new file: c/3
#
[root@action_test /shell/yaobin_test]# git commit -m "first add file"
[master (root-commit) 409f288] first add file
Committer: root <root@action_test.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
If the identity used for this commit is wrong, you can fix it with:
git commit --amend --author='Your Name <you@example.com>'
4 files changed, 9 insertions(+), 0 deletions(-)
create mode 100644 README.md
create mode 100644 a/1
create mode 100644 b/2
create mode 100644 c/3
[root@action_test /shell/yaobin_test]# git config --global user.name "chenyaobin"
[root@action_test /shell/yaobin_test]# git config --global user.email qwerty0113250159@126.com
[root@action_test /shell/yaobin_test]# git status
# On branch master
nothing to commit (working directory clean)
[root@action_test /shell/yaobin_test]# git push -u origin master
Counting objects: 9, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (9/9), 501 bytes, done.
Total 9 (delta 0), reused 0 (delta 0)
To git@slave2:root/yaobin_test.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
hello
最后总结:发现它的一些操作和github很像!!