I Have a problem with git My problem is the following, when I make a pull:
git pull origin example
Until there Perfect!!, Then I make a
rm -Rf rootdirectory
Then
git commit -am "Delete files"
and Then again I make a pull because I need this files
git pull origin example
but it isn't get again the rootdirectory
This is a message:
Already up-to-date.
How I can do for get the files with git pull again?
The reason git pull does not change anything is that you are not pulling data from the remote repository, you are pulling changes . And there are no changes for git to pull!
Git is not a data store. It's a version control system
However, if you want to checkout the previous state you can easily do that:
git checkout HEAD~1
This means you are resetting your working copy to the previous state before the latest commit.
If however, you would like to completely remove the commit that deleted the files, you can do that as well:
git reset --hard HEAD~1
Am I right in thinking that you're used to Subversion, where if you deleted the files, and then did a svn update
, the files would get repopulated? Me, too.
In git, you have to do git checkout
to bring files out of the repo. You can also use git reset --hard
to update the files, but doing so will wipe out any changes in the working directory.
This is the way git works. After pulling origin/example
and committing your change ("Delete files") your local repo is ahead of origin/master
by that 1 commit:
A---B---C origin/master
\
D master
Where D
is your Delete files
commit. Another git pull
gives you Already up-to-date
because there are no new commits on origin/master
that could be pulled into your local repo.
To "get the files again", you can either undo you last commit:
git checkout HEAD~1
Or you can reset your local repository to match the remote repository:
git reset --hard origin/master
Go to the directory where the files are deleted, make sure you are on the branch you want and type "git checkout ." this will bring back the files you deleted on your current branch.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.