我写了一个项目很长时间,但是不会用git,一直没有机会实践,今天进行了实践。我在项目中首先运行了下面几条命令:
git init (初始化项目)
git add . (把所有信息添加到git本地控制)
git commit -m "自己随便写,最好是根据功能写"
测试能否连接到github,输入以下命令:
ssh -T git@github.com
如果测试成功会出现一大堆英文说成功。
git remote add origin <url>
前提是你在github上创建了仓库:
出现了以下错误:
warning: no common commits
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
From github.com:WangXin1708/GraphicCreateGrid
* [new branch] master -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> master
这样你可以 git branch --set-upstream-to=origin/master
然后输入
git pull --allow-unrelated-histories
然后直接git push