克隆远方仓库的项目到本地:git clone url.git
注意,一定要有.git,不是只有一个url就可以了
查看本地分支:git branch
这时候一般只有master分支
查看远方仓库分支:git branch -a
如果远方仓有好几个分支,举例如下:第一行表示自己这个项目是fork别人的,指向的是原作者的master。第二行表示自己远方主分支master。第三行表示远方分支exercise。
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/exercise
克隆远方分支到本地:git checkout -b exercise origin/exercise
建立本地分支exercise并从master切换到它,将远方分支exercise拷贝到本地分支exercise。
修改文件,这里用modified_file指代。
如果想删除远方仓库文件:
git rm --cached file
git commit -m "your note"
git push origin branch
提交文件:
git add modified_file
git commit -m "your notice for this modification"
传回远方分支:git push origin exercise
以上是完整的拷贝至本地流程。
为本地项目建远程仓库:git remote add origin https://github.com/your-name/your-project.git