Skeets
Skeets

Reputation: 4828

Creating a git repo from an existing project, and running `git diff`

I have an (outdated) copy of a git repository, without any git tracking. (no .git folder at all)

I want to see how different it is from the original git repository, without affecting the remote git repository.

This is what I've tried so far:

git init
git remote add origin {origin_URL}
git fetch --all
git --no-pager diff -R origin/master --numstat

... but this just lists ALL the files, and says that none of them exist locally.

Maybe this is because I haven't added any files to git tracking locally?

Would I have to make a new local branch, commit changes to it, and then compare that to the origin/master branch (and then delete the branch, because I don't need it)? Or is there a way to do it without creating a branch?

Upvotes: 3

Views: 257

Answers (1)

Ayman Nedjmeddine
Ayman Nedjmeddine

Reputation: 12689

You can just add the whole project to the staging area (tracking), view the changes comparing to your remote repository, and then unstage the added files.

git init
git remote add origin {origin_URL}
git fetch --all
# stage files
git add .
git --no-pager diff -R origin/master --numstat
# unstage them
git reset

Upvotes: 2

Related Questions