How to sync the local folder with the Git Repository on NitrousIO

不想你离开。 提交于 2019-12-08 04:37:22

问题


First - I've created the git repository and also created the local repo of the same on my local system. Second - Worked on my local system and did some changes and pushed the changes on to the Git repository such that my local system source and git repository are in sync now

Now, Instead of working on my local system, I wanted to work on NitrousIO. Hence created the folder same as my git repository name and did 'git .init' as well. Basically this is the Ruby on Rails application, hence followed 'rails new RKsJobs_Board' to set up the folder and then git .init

What I need is: As the remote git repository is up-to-date with the source code, I would like my NitrousIO folder to be in sync with the remote repository.

How can I achieve this ?

I tried this on Nitrous from the root directory like below:

action@rksrailszone-182221:~$ git checkout -- RKsJobs_Board                                                                                                                                           
error: pathspec 'RKsJobs_Board' did not match any file(s) known to git.

I also tried this on Nitrous from the actual directory like below:

action@rksrailszone-182221:~/RKsJobs_Board$ git checkout -- RKsJobs_Board                                                                                                                             
error: pathspec 'RKsJobs_Board' did not match any file(s) known to git. 

I know something fishy is missing to get it work but unable to find out myself.

Let me know if you guys can help..


回答1:


If you just did a git init ., the local git repo is empty and has no index for you to checkout.

You would need to add a remote repo url

git remote add origin /url/to/remote/repo
git fetch
git checkout master origin/master (or) git checkout master && git reset --hard origin/master

That would give you the content of the remote repo in your local repo history and working tree.

Note - Before following the steps, please ensure to have the empty folder then start with git init . and other steps mentioned above



来源:https://stackoverflow.com/questions/28039173/how-to-sync-the-local-folder-with-the-git-repository-on-nitrousio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!