Git-udemy part2 about Github

1.github

game:flappy bird(github)

2048游戏

git clone http://github.com/gabrielecirulli/2048.git

 

2. 生成github ssh公钥

key1.open terminal->

ssh-keygen -t ed25519 -C "your_email@example.com"

key2.Your public key has been saved in->

 /Users/xxx/.ssh/id_ed25519.pub

key3.go to .pub and copy-paste to github->

cat /Users/xxx/.ssh/id_ed25519.pub

 

3.开始push到github了。

git remote

git remote -v (可以看到push的url)

########## 如何从本机push到github上,分两步

step1:git remote add origin https://github.com/zhaoxue428/GitIngnoreDemo.git(第一次push的时候直接在新创建仓库的时候可以看到,直接粘贴就好)

也可以加一步:git branch -M main 命令的含义是将当前所在分支的名称修改为 main

step2:git push -u origin main(第二次push的时候可以直接走:git push origin main

########## 

git push origin cat:main(从本地cat分支到远程main分支)

########### 如果仅仅是想提交一个新的分支,分两步

git switch -c "dog" 

git push origin dog

 

4.如何把github上的仓库克隆到本机上

git clone https://github.com/zhaoxue428/chicken-dogs.git

?被警告克隆了一个空的仓库时,可以直接cd该文件夹下,touch一个新文件,再push上去,这样就建立了本地和远程的链接(push的时候push origin master or push origin main(选择readme))

 

5.视频106非常完美的展示了修改默认分支名字;创建多个分支;并分别push到github上;分支merge到main上;多个merge时分支冲突的合并;产生冲突后要习惯git status,commit

 

6.git branch -r(显示远程仓库的分支列表) 

 

7.git checkout origin/food

 

8.git switch movies(有分支则切到;否则创建新movies)

 

9.origin/HEAD:这是远程仓库的默认分支

 

10.git fetch origin(远程仓库 origin 中获取最新的提交和分支信息到本地仓库,但不自动合并到当前分支。)

 

11.两种删除

rm chicken.txt

rm -rf chicken.txt

 

12.在github上通过html文件 结合github-setting-gitpages 展示网站(仅用于静态网站)

 

 


git fetch origin 从远端获得最新代码,但并不自动合并 

pull 请求 

134课 合并有冲突的拉取 请求

 

合并分支有两大工作流程

一个时重建基础;一个是合并

 

可以让git log的记录看起来更清晰

git switch feature

git rebase master(只能用于分支上的修改,只能重写分支上的git记录,不能用于master主分支上的)

git rebase master 将当前分支的提交基底移动到 master 分支的最新提交之后,并将当前分支的所有提交应用到该位置。

git commit -am "add init infor"

git diff fea..master 用于比较两个分支之间的差异

用rebase修改提交的内容(数字代表想要回溯到倒数第几个)详细见视频149

git rebase -i HEAD~4

cat app.js 是一个命令行命令,用于在终端中显示名为 app.js 的文件的内容。

 

git tag

git tag -l "v17*"  

 git diff v17.0.0 v17.0.1

git tag v17.0.2

git tag -a v17.1.0

git show v17.1.0

 

config文件设置(加了local是配置全局设置)(该文件内可以做超级多的设置,比如branch的颜色)

git config user.name

git config --local user.name(本地仓库)

git config --local user.name "chicken little"

git config user.name

git config --local user.name

git config --local user.email "chicken@gmail.com"

 
git config --glaobal user.name(全局)
git config --glaobal user.email
 
在.gitconfig文件里面设置alias
 
git reflogs
git reflogs show HEAD 
git reflog
 
164~174没怎么看
posted @ 2024-02-29 01:04  continentliang  阅读(2)  评论(0编辑  收藏  举报