问题
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