先是gitignore无法用txt直接生成 ,可以在git bash输入该代码
mv gitignore.txt .gitignore
新项目按如下操作上传至github
1. 在github上面新建一个repo 红线的链接之后要用到
2. 在本地的项目内用git bash打开 输入git init 移位在本地上也建立一个git repo
3.弄好gitignore文件后使用git status查看状态 发现有红色的untracked files 可以选择全部或者部分上传至github的repo
4. 这里把gitignore文件格式改正后 使用
git add . 来track 所有项目内的文件(文件较多过程就较长)再用
git status来检查文件是否变绿色表示已经tracked记录了
5. 使用
git commit -m "comment part"来commit. "git commit is used to create a snapshot of the staged changes along a timeline of a Git projects history."我的理解就是生成一个快照来存档每次的项目更改
6. 可以git log使用来查看每次的快照(commit)
7. 再次使用 来检查已经生成了最近改动的快照了(如果又改了文件什么会有显示的)
这时候使用
git remote add origin 在github网站上建立repo的链接来告诉本地 有个remote的名字叫origin的repo 使用git remote可以查看相关联的remote repos
The
git remote -v (or
git remote -vv) command is used in Git to display the URLs of the remote repositories that are associated with your local repository. The
-v
option stands for "verbose," and it shows the fetch and push URLs for each remote repository, which can be helpful in understanding where your code is being pushed to or pulled from. 这段是gpt解释 意思就是查询和本地repo相关联的远程repo有几个是什么
8.最后使用git push -u origin master来上传到建立的github网站的repo 这里传的是master branch可以更换成其他的branch
(目前先写这么多 还有常见的不同branch怎么merge也是个问题 还有使用github很吝啬的1GB LTS文件如何操作 之后再写)