Today, the Internet learned to use git tag, and brushed up the local connection to the whole process of the remote, and then record it
git remote management :
Applets are a lot of knowledge, but say all the knowledge in a project, it will be obvious bloated
If a branch to manage every branch of knowledge about some point, then there will be a lot of branches, branch management will be very troublesome, cumbersome and branch switching, etc.
The teacher finally decided to use the tag to manage the project
A knowledge point marked with a tag,
Then to see what knowledge is switched to the corresponding tag
After the first complete presentation of knowledge points, it will be marked with a tag, then the second will not be demonstrated on the basis of knowledge tag1 on, this time will perform: git reset --hard version will fall back to that version of the initialization
After the re-presentation of the second point of knowledge
We perform: git chekout tag1
git reset --hard fallback to initialize version
git chekout tag2 like to switch to a corresponding knowledge
We now built a small program projects, have not yet incorporated into the management git
First, we need to need to project in our town right into the git bash here
Open git command-line tool
Execute git init to initialize a local repository within the project will appear after .git file, which is a hidden file can run git command to view the file can also organize files in folders and search options --- --- --- Hidden View files and folders select show hidden files to see or hide hidden files, general computer hidden files are hidden by default
Then execute git the Add. (Dot) to add all files to which the suspension area
Then execute git commit -m "initialization option applet projects" submitted at this git had the management of our projects
Currently only a local git, and not to any hosting a remote repository
Then we need to create a repository on a remote code cloud (on the course is on github, and a cloud of code)
Click to create a warehouse, write the name of the warehouse, because the path will be generated automatically (you can also customize this feature is not available before)
Then I created a private warehouse, you can create a total warehouse (others can see), I am here to choose a private warehouse, because the total warehouse will choose something else, so I did not bother selection
I did not let readme.md automatically generated files, listen to the teacher says in a prominent program to project an eyesore
Then click the Create button, some methods (codes) Tips will connect to a remote repository
Then we first local warehouse and the warehouse has just created a connection
git remote add origin warehouse address .git
After the local repository and remote repository connections, the native code to upload it
Initial upload need to add the parameter -u
git push -u origin master
After performing too, will enter the account name and password and then the local repository of code that will be uploaded to a remote repository
Next we practice about playing tag
In index.wxml casually add the code
Then execute the following command in the git administrative interface
git add. submit all files to the cache area
git commit -m "practice playing tag" submit it
git tag 01_ knowledge to practice playing tag 1 play tag
We can enter the git tag command to view the current play all tag
Just when adding the code to modify the first knowledge point, we have fought a tag
We can look at all the submissions (we have already submitted twice)
git log
然后我们接下来要讲第二个知识点,这时我们就可以 回退到初始代版本 然后再写第二个知识点
版本回退到最初版本:
git reset --hard 黄色的版本号 (--hard 参数是 强制回退到指定版本)
现在我们已经回退到初始化项目 这个版本了,我们可以写第二个知识点了
此时看一下刚才的第一个知识点 写的内容已经消失了
然后我们再在项目中加点代码,比如说这代码就是第二个知识点,讲完了
我们再做一次提交,给知识点二打个tag
git add .
git commit -m "练习版本回退"
git tag 02_知识点2练习版本回退
然后再查看一下所有的tag
git tag
再查看一下提交日志:
git log
接下来我们可以将这两个tag,推送到远程
git push --tags (将这两个tag 推送到远程 不是git push origin master) 依然会让输入 码云的账号和密码 之后就会 推送到远程
之后我们在远程仓库就会看到这两个tag了
我们如果想在远程查看每个知识点,就点击对应的tag切换一下就行,很方便
当然,在本地想查看不同tag的代码时
我们可以执行
get checkout 01_知识点一练习打tag (我们写出 01 后敲一下tab键 会自动补齐的)
此时 知识点1的代码就在本地了
同样的在本地查看 知识点2
get checkout 02_知识点2练习版本回退 (同样写出 02 后敲一下tab键 会自动补齐 tag)
此时我们就可以在本地查看 知识点2了 很方便
之后我们如果想继续讲第三个知识点,我们就可以 执行 git reset --hard 版本号 来回到最初的小程序初始化代码 (提交的版本号可以通过 git log查到)
git reset 版本号是回不去最初版本的 因为 我们有更改,所以需要加上--hard参数
。