自学学习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 ..." to update what will be committed)
  (use "git checkout -- ..." 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 
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://[email protected]':
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://[email protected]':
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

你可能感兴趣的:(自学学习1)