使用git的方法
環境- 觸手可及的一部份周圍事物、條件、影響等的總和。
2. 自然和人造物質的自然和社會條件。
3. 所居住或存在於其中的空間、地區、地區。
4. 環境的自然或社會因素對人、動物或植物的影響。
5. 包括所有生物及其生活或生存的地方。
6. 結合它和所佔有的事物和追求的結果。
我在VMware Workstation 14 Player中创建了一个客户机。
[root@centos74 ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@centos74 ~]# uname -r
3.10.0-693.el7.x86_64
ゲストマシン------ Internet --------- GitHub
事前准备包括做好计划和准备材料。
2.1 在GitHub上创建帐户。
在 GitHub 上创建一个账户。
2.2 安装Git
[root@centos74 ~]# yum -y install git
[root@centos74 ~]# git --version
git version 1.8.3.1
创建存储库的方法有哪些?
4.1 GitHub的配置
4.2 本地(客户机)的设置
[root@centos74 git]# git config --global user.name "hana-shin"
[root@centos74 git]# git config --global user.email "xxx@example.com"
[root@centos74 git]# git init
Reinitialized existing Git repository in /root/git/.git/
[root@centos74 git]# echo "# test1" >> README.md
[root@centos74 git]# git add README.md
[root@centos74 git]# git commit -m "first commit"
[master (root-commit) e496a22] first commit
1 file changed, 1 insertion(+)
create mode 100644 README.md
[root@centos74 git]# git remote add origin https://github.com/hana-shin/test1.git
[root@centos74 git]# git push -u origin master
Username for 'https://github.com': hana-shin
Password for 'https://hana-shin@github.com':
Counting objects: 3, done.
Writing objects: 100% (3/3), 221 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/hana-shin/test1.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
上传文件到5个仓库的方法
[root@centos74 git]# touch test.txt
[root@centos74 git]# echo "12345" > test.txt
[root@centos74 git]# cat test.txt
12345
[root@centos74 git]# git add test.txt
[root@centos74 git]# git commit -m "first new file"
[master 3f97dc1] first new file
1 file changed, 1 insertion(+)
create mode 100644 test.txt
[root@centos74 git]# git push origin master
Username for 'https://github.com': hana-shin
Password for 'https://hana-shin@github.com':
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 284 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/hana-shin/test1.git
e496a22..3f97dc1 master -> master
删除GitHub文件的步骤
[root@centos74 git]# ls
README.md test.txt
[root@centos74 git]# git rm test.txt
rm 'test.txt'
[root@centos74 git]# ls
README.md
[root@centos74 git]# git add .
[root@centos74 git]# git commit -m "delete test.txt"
[master 4c94841] delete test.txt
1 file changed, 1 deletion(-)
delete mode 100644 test.txt
[root@centos74 git]# git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
Username for 'https://github.com': hana-shin
Password for 'https://hana-shin@github.com':
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1/1), done.
Writing objects: 100% (2/2), 236 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
To https://github.com/hana-shin/test1.git
3f97dc1..4c94841 master -> master
将远程存储库复制到本地存储库的方法是克隆(clone)。
[root@centos74 ~]# mkdir project
[root@centos74 ~]# cd project/
[root@centos74 project]# git clone https://github.com/hana-shin/test1
Cloning into 'test1'...
remote: Counting objects: 8, done.
remote: Compressing objects: 100% (5/5), done.
Unpacking objects: 100% (8/8), done.
remote: Total 8 (delta 2), reused 6 (delta 0), pack-reused 0
[root@centos74 project]# ls
test1
[root@centos74 project]# cd test1/
[root@centos74 test1]# ls
README.md test.txt
[root@centos74 test1]# cat test.txt
12345
检出文件的方法(checkout)。
[root@centos74 test1]# ls
README.md test.txt
[root@centos74 test1]# rm test.txt
rm: 通常ファイル `test.txt' を削除しますか? y
[root@centos74 test1]# ls
README.md
[root@centos74 test1]# git checkout .
[root@centos74 test1]# ls
README.md test.txt
Y 记事
[root@server ~]# git clone https://github.com/hana-shin/kernel-module-programming.git
[root@server ~]# cd kernel-module-programming/
[root@server kernel-module-programming]# mkdir test
[root@server kernel-module-programming]# touch test/README.md
[root@server kernel-module-programming]# git add test
[root@server kernel-module-programming]# git commit -m "Add Directory"
[root@server kernel-module-programming]# git push -u origin master
[root@server kernel-module-programming]# rm -f -r test
[root@server kernel-module-programming]# git add --all test
[root@server kernel-module-programming]# git commit -m "Delete Directory"
[root@server kernel-module-programming]# git push -u origin master
[root@server 01_MachineA]# ls
README.md dump-1-install-3.sh dump-1-install-4.sh dump-install.sh
[root@server 01_MachineA]# git add --all
[root@server 01_MachineA]# git commit -m "First Commit"
[root@server 01_MachineA]# git push -u origin master
[root@server include]# ls
README.md define.sh functions.sh test
[root@server include]# rm -f test
[root@server include]# git add --all
[root@server include]# git commit -m "Delete File"
[root@server include]# git push -u origin master
[root@server 01_MachineA]# vi dump-1-install-3.sh
[root@server 01_MachineA]# git add dump-1-install-3.sh
[root@server 01_MachineA]# git status
[root@server 01_MachineA]# git commit -m "Mod File"
[root@server 01_MachineA]# git log
[root@server 01_MachineA]# git push -u origin master
[root@kvm src]# cd 01_MachineA/
[root@kvm 01_MachineA]# ls
README.md dump-1-install-3.sh dump-1-install-4.sh dump-install.sh
[root@kvm 01_MachineA]# git pull origin master
参考资料
只需要一个选项,用中文将以下内容进行改述:
“今さら聞けない!GitHubの使い方【超初心者向け】”
“ローカルで作業ブランチを作成しリモートへPushするまでの手順”
“サルでもわかるgit入門”
“git / GitHubからいらないファイルを削除する”
“Git の基本 – Git リポジトリの取得”
hana-shin
以下是改述后的内容:
“对于初学者来说,如何使用GitHub【超级入门教程】”
“从创建本地工作分支到推送到远程的步骤”
“一看就懂的Git入门”
“删除不需要的文件的git / GitHub方法”
“Git基础 – 获取Git存储库”
hana-shin
使用个人访问令牌。