On Thursday, July 19, 2012 11:18:09 PM UTC+2, TSU wrote:
>
> Instead of "git rm" I removed files in local copy using a non-git external 
> application. How to sync files from github again? Looks like git will 
> download only changes from what was downloaded before and doesn't recognize 
> files no longer exist locally.
>

If you remove files from your work-tree, it is quite easy to get them out 
of the repository again:

git checkout path/to/file
 

> Have tried "git reset --hard master" and "git clean -df" but still results 
> in error when trying to "git fetch branch gh-pages" (fatal: 'branch' does 
> not appear to be a git repository). Have verified gh-pages branch exists on 
> github  
>

git reset --hard will change your work-tree into being how it was in your 
(local) branch 'master'. It basically means "Destroy all changes I have 
made since the last commit!" and is hence a bit dangerous.

git clean -df will remove all untracked files and directories (that are not 
ignored). Also use with caution if you have created new files.

git fetch will download the contents of a remote repository. As the first 
argument, it takes repository name, but you are specifying 'branch', which 
does not sound like a remote name. To see what your remote is called, do

git remote

I'll guess that it's called 'origin' (default when you clone from a 
repository). So the right command would be:

git fetch origin gh-pages

(although it's pretty common to just do 'git fetch', as that will update 
all branches for the remote).

I seem to be able to be able to query the remote server for branches and 
> use checkout to switch to the gh-pages branch but am then stuck.
>

If you want to work on the branch gh-pages, do 

git checkout gh-pages

You should see an output like this:

Branch gh-pages set up to track remote branch gh-pages from origin.
Switched to a new branch 'gh-pages'

If you already have a local branch called 'gh-pages', make sure that it is 
tracking the proper branch on github/origin like this:

git remote show origin

(at the bottom of the output, you should see how local branches are 
configured. If it doesn't look right, please paste the contents in here).

If your local 'gh-pages' branch has been misconfigured, or doesn't track at 
all, you can correct this:

git branch --set-upstream gh-pages origin/gh-pages

Now you should be able to push and pull changes from github in this branch.

If that doesn't work, well, just post back here.
 

> Speculate I need to know where local git repo exists so I might start with 
> a clean slate, but I've found that local tracking seems to be stored not in 
> the .git subfolder of the local repo copy but somewhere else. Am reluctant 
> to remove my global config although I suppose that should be easy to copy 
> and re-enter.
>

Yeah, your global config shouldn't contain much more than your name and 
email address. Just paste the whole file in here if you want us to have a 
look at it for you.

 

> Hoping for guidance how to recover from this dumb act, but I suppose could 
> be useful of the local copy gets corrupted somehow also.
> There is very little history on this machine so can pave and re-build git 
> if that's the easiest way (although prob least educational).
>

Education ftw! I warmly recommend having a read through the Git Book by the 
way, especially Ch. 3 on branches: http://git-scm.com/book

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/git-users/-/qkbxVg8TGCYJ.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.

Reply via email to