自学学习1

git账号申请及使用


建立账号并fork自学习项目

把fork后专案克隆到本地

~  git clone https://github.com/pixel2066/the-craft-of-selfteaching.git
Cloning into 'the-craft-of-selfteaching'...
remote: Enumerating objects: 2028, done.
remote: Total 2028 (delta 0), reused 0 (delta 0), pack-reused 2028
Receiving objects: 100% (2028/2028), 37.11 MiB | 1.02 MiB/s, done.
Resolving deltas: 100% (1319/1319), done.

建立本地分支版本

~  cd the-craft-of-selfteaching
~/the-craft-of-selfteaching ⮀ master ⮀ 
~/the-craft-of-selfteaching ⮀ master ⮀ git checkout -b version-1
Switched to a new branch 'version-1'
~/the-craft-of-selfteaching ⮀ version-1 ⮀

查看远程仓库地址和清除此版本所有改动

 ~/the-craft-of-selfteaching ⮀ version-1± ⮀ git remote -v
origin  https://github.com/pixel2066/the-craft-of-selfteaching.git (fetch)
origin  https://github.com/pixel2066/the-craft-of-selfteaching.git (push)
~/the-craft-of-selfteaching ⮀ version-1± ⮀ git checkout .
~/the-craft-of-selfteaching ⮀ version-1 ⮀

在分支版本中修改操作

 ~/the-craft-of-selfteaching ⮀ version-1 ⮀ code .
在git版本中输入code .命令后启动Visual Studio Code编辑,在左边可看到此版本所有文件

git修改、合并操作
首先查看状态为:未修改

~/the-craft-of-selfteaching ⮀ version-1 ⮀ git status
On branch version-1
nothing to commit, working tree clean
在my-notes.py中增加内容

增加后查看版本状态:发现有变化

~/the-craft-of-selfteaching ⮀ version-1 ⮀ git status
On branch version-1
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   my-notes/my-notes.py

no changes added to commit (use "git add" and/or "git commit -a")

~/the-craft-of-selfteaching ⮀ version-1± ⮀ git diff
diff --git a/my-notes/my-notes.py b/my-notes/my-notes.py
--- a/my-notes/my-notes.py
+++ b/my-notes/my-notes.py
@@ -0,0 +1 @@
+启动自学习。
\ No newline at end of file

提交修改合并版本

~/the-craft-of-selfteaching ⮀ version-1± ⮀ git add .
~/the-craft-of-selfteaching ⮀ version-1± ⮀ git commit -m "update my-motes"
[version-1 0899989] update my-motes
 1 file changed, 1 insertion(+)
~/the-craft-of-selfteaching ⮀ version-1 ⮀ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
~/the-craft-of-selfteaching ⮀ master ⮀ git merge version-1
Fast-forward
 my-notes/my-notes.py | 1 +
 1 file changed, 1 insertion(+)

~/the-craft-of-selfteaching ⮀ master ⮀ git log
commit c5a043c1ca6baf80a031cd4cf1479747aff4f064 (HEAD -> master, version-1)
Author: Pixel2066 <pixel2066@163.com>
Date:   Sun Apr 7 17:51:19 2019 +0800

    update my-motes

往github上push本地修改

#push主干
~/the-craft-of-selfteaching ⮀ master ⮀ git push -u origin master
Username for 'https://github.com': pixel2066
Password for 'https://pixel2066@github.com':
Counting objects: 8, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (8/8), 697 bytes | 232.00 KiB/s, done.
Total 8 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 1 local object.
To https://github.com/pixel2066/the-craft-of-selfteaching.git
   a6c2c19..c5a043c  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

#push所有版本分支
 ~/the-craft-of-selfteaching ⮀ master ⮀ git push --all origin
Username for 'https://github.com': pixel2066
Password for 'https://pixel2066@github.com':
Total 0 (delta 0), reused 0 (delta 0)
remote:
remote: Create a pull request for 'version-1' on GitHub by visiting:
remote:      https://github.com/pixel2066/the-craft-of-selfteaching/pull/new/version-1
remote:
To https://github.com/pixel2066/the-craft-of-selfteaching.git
 * [new branch]      version-1 -> version-1
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1. 安装 Github 查看是否安装git: $ git config --global user.name "...
    Albert_Sun阅读 14,660评论 9 163
  • Git常用语法 [TOC] Git简介 描述 ​ Git(读音为/gɪt/。)是一个开源的分布式版本控制系统,...
    君惜丶阅读 9,222评论 0 13
  • 声明:这篇文章来源于廖雪峰老师的官方网站,我仅仅是作为学习之用 Git简介 Git是什么? Git是目前世界上最先...
    横渡阅读 9,392评论 3 27
  • Git教程 一、Git简介 1.1. Git的诞生1.2.集中式的vs分布式 二、安装Git 三、创建版本库 四、...
    曹渊说创业阅读 4,518评论 0 2
  • 【用户画像】 一、基本情况 1.用户对象职业:不限 2.用户对象细分:宝妈 3.学历水平:不限 4.用户年龄:20...
    凯文Kevin_d78d阅读 1,040评论 0 0

友情链接更多精彩内容