【自用】2.git应用

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值