Reputation: 19
all
I have been asked to clone a repository hosted on cloud server using ssh onto our local server..I did that using "git clone ssh://server path "..once i do this., I see .git folder created and all the files..
now for next time if the code is changed on cloud server., i have been asked to run this onto local machine
git fetch git tag (tag number is the largest tag number i see on the list- probably every commit was made will have new tag number..i am just assuming this way) git checkout
my question is when i run git fetch., its going to update my local copy of remote repository (but dont merge with my current local branch)..is that correct ?
when I run git tag - it gives me list of tags..from where this information is pulled from ? does this contacts remote cloud server to get the tags ? or it will get it locally since I did git fetch in the first step ?
git checkout - i really dont understand this step what it does ?..does it updates local files with the changes made on this specific tag number ?..if yes, that means it copies the modified files from local copy of remote repository to my current working directory ?
Please clarify..its all time confusing for me.
shan
Upvotes: 0
Views: 3338
Reputation: 12898
The time you invest in understanding how git works, will be paid back many times. A lot of tutorials , and even books , are available for free. If you are coming from subversion or similar, this 'subversion re-education' chapter might be helpful (even though it's part of a mercurial tutorial...) And you should of cause check out this SO question: Git for beginners: The definitive practical guide
Your local repository consist of the actual files, and the .git folder which contain information about all changes and how they relate to each other.
When you have modified a local file, staged it with git add
, and committed it with git commit
, the changed parts are stored as a set of diffs. These diffs gets a unique I'd, a ref, and are stored together with the previous changes ref.
fetch will not modify your local files, but will bring down information about what files (changes, branches, tags) that are available on the remote.
tag is a named reference.
checkout puts your local fils in a certain 'state'. So if you specify a tag when you checkout, all files will be equal to how they were when the tag was created.
Upvotes: 0
Reputation: 2743
Yes, using git pull/fetch will copy from the rempte server, most other commands like tag/branch/checkout are local. Checkout http://ndpsoftware.com/git-cheatsheet.html for the full list.
Git is distributed so you get copies of branches and history from remote servers stored localy.
checkout will give you a version of a file or a whole branch/tag, see
git help checkout
for more.
Upvotes: 2