1.GitHub功能介绍
1.记录多个版本
2.查看历史操作,可以进行版本回退和前进的控制
3.多端共享代码,自动合并
2.创建仓库&项目的克隆拉去和推送
1.在git网页上创建新的仓库
2. 克隆ssh地址
$ git clone git@github.com:tytgit/AutoTest.git
Cloning into ‘AutoTest’…
warning: You appear to have cloned an empty repository.
3.推送
65155@DESKTOP-R1M1DOQ MINGW64 ~/.ssh/AutoTest (main)
$ git commit -m “2222”
[main (root-commit) 26ad384] 2222
1 file changed, 1 insertion(+)
create mode 100644 test.txt
65155@DESKTOP-R1M1DOQ MINGW64 ~/.ssh/AutoTest (main)
$ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 220 bytes | 220.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:tytgit/AutoTest.git
- [new branch] main -> main
4.拉取
git pull
3.项目的分支操作
3.1创建分支
65155@DESKTOP-R1M1DOQ MINGW64 ~/.ssh/AutoTest (main)
$ git branch
- main
65155@DESKTOP-R1M1DOQ MINGW64 ~/.ssh/AutoTest (main)
$ git branch -a
- main
remotes/origin/main
65155@DESKTOP-R1M1DOQ MINGW64 ~/.ssh/AutoTest (main)
$ git checkout -b branch1
Switched to a new branch ‘branch1’
65155@DESKTOP-R1M1DOQ MINGW64 ~/.ssh/AutoTest (branch1)
$ git branch
- branch1
main
65155@DESKTOP-R1M1DOQ MINGW64 ~/.ssh/AutoTest (branch1)
$ git branch -a
- branch1
main
remotes/origin/main
65155@DESKTOP-R1M1DOQ MINGW64 ~/.ssh/AutoTest (branch1)
$ vim test.txt
65155@DESKTOP-R1M1DOQ MINGW64 ~/.ssh/AutoTest (branch1)
$ cat test.txt
111111
2 branch1
65155@DESKTOP-R1M1DOQ MINGW64 ~/.ssh/AutoTest (branch1)
$ git add test.txt
warning: in the working copy of ‘test.txt’, LF will be replaced by CRLF the next time Git touches it
65155@DESKTOP-R1M1DOQ MINGW64 ~/.ssh/AutoTest (branch1)
$ git commit -m “提交到分支1”
[branch1 9ba15bc] 提交到分支1
1 file changed, 1 insertion(+)
65155@DESKTOP-R1M1DOQ MINGW64 ~/.ssh/AutoTest (branch1)
$ git push
fatal: The current branch branch1 has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin branch1
To have this happen automatically for branches without a tracking
upstream, see ‘push.autoSetupRemote’ in ‘git help config’.
65155@DESKTOP-R1M1DOQ MINGW64 ~/.ssh/AutoTest (branch1)
$ git push --set-upstream origin branch1
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 284 bytes | 284.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: Create a pull request for ‘branch1’ on GitHub by visiting:
remote: https://github.com/tytgit/AutoTest/pull/new/branch1
re