Reputation: 8691
I have just created a git repository and been able to check in the code by staging it and then executing the git push. The problem that I am facing is while taking the latest. What I understand is that the directory name in git should match the directory name in your system.
My working folder is C:\Test\MRDB.WEB.UI\
To get the latest i did the following steps 1. Go to the working folder in command prompt cloned the directory 2. git clone https://github.com/ranjitmenon/MRDB.git 3. git init 4. git fetch MRDB
When I execute the third step it pulls the all the files into my system with MRDB folder as parent. What I am looking at is that when I execute from the path C:\Test\MRDB.WEB.UI\ only the contents of the file need to get updated in this path. Currently it is adding MRDB folder with files under this path. The other way I am thinking is go one folder up that is C:\Test\ , add a folder in git under MRDB called MRDB.WEB.UI.
I am not sure how to go about it as I am new to git. Please help
Upvotes: 0
Views: 65
Reputation: 29678
git init
is done once at the start to setup/create an empty repository. There is no need to re-run it on an existing repository unless you need to pick up newly added templates or to move the repository to another place.
Given that you already have an existing repository in Github, you only need to do git clone https://github.com/ranjitmenon/MRDB.git
on your local directory. This is also only done once at the start when setting-up a copy of your repo on your local machine.
I tried cloning your repo and it creates a MRDB
folder like so:
E:> git clone https://github.com/ranjitmenon/MRDB.git
Cloning into 'MRDB'...--
E:\MRDBMRDB
|- .git
|- e2e
|- src
|- ..other files..
From here, all you need to do is to cd
to the MRDB
folder and do all your git operations there. There is no MRDB.WEB.UI
folder. The top-level folder of your repo is MRDB
, as shown in Github as "ranjitmenon/MRDB".
Now everytime you need to get the latest code changes from your remote repo, you just need to do this in the MRDB
folder:
git fetch origin
But git fetch
only updates your copy of the remote branches, which in this case is the origin/master branch in Github. It does not update the files on your local branches. You can check the difference by doing:
git log origin/master
git log master
From here, to actually update the files on your local master branch, you can either do one of the following:
git merge origin/master
(merges the remote master to local master)git pull
(combination of git fetch
and git merge
)Note that, if you need some branch other than master, you need to do git checkout first on that branch, before pull
or merge
.
What I understand is that the directory name in git should match the directory name in your system
git clone
should already handle matching the directory names (i.e. it created the MRDB
folder on your local PC to match the MRDB
folder in Github). What I think is more relevant is that the branch names in your local copy should match those in the remote copy.
Upvotes: 0
Reputation: 1377
So you have listed four 'step' that you have followed
These steps, as listed, are not ones to execute one after another. I encourage you to read the git documentation for specific details on those commands.
If I understand you correctly, you want to get 'the latest' off of github. Here is what you do:
cd C:\Test
git clone https://github.com/ranjitmenon/MRDB.git MRDB.WEB.UI
If the directory MRDB.WEB.UI already exists, then I assume the above steps have already been taken. In which case we shall update a previously cloned repository with the latest from github:
cd C:\Test\MRDB.WEB.UI
git fetch origin
git merge origin/master
Upvotes: 1