从现有项目创建一个git repo,并运行`git diff`. [英] Creating a git repo from an existing project, and running `git diff`

查看:59
本文介绍了从现有项目创建一个git repo,并运行`git diff`.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个git存储库的(过时的)副本,没有任何git跟踪.(根本没有 .git 文件夹)

我想看看它与原始git存储库有什么不同,而又不影响远程git存储库.

这是我到目前为止尝试过的:

  git初始化git remote add origin {origin_URL}git fetch --allgit --no-pager diff -R origin/master --numstat 

...但这只是列出了所有文件,并说它们都不存在于本地.

也许这是因为我还没有在本地git跟踪中添加任何文件吗?

我是否必须创建一个新的本地分支,对它进行更改,然后将其与origin/master分支进行比较(然后删除该分支,因为我不需要它)?还是有一种无需创建分支就可以做到的方法?

解决方案

您可以将整个项目添加到暂存区域(跟踪),查看与远程存储库相比的更改,然后取消暂存已添加的文件.

>

  git初始化git remote add origin {origin_URL}git fetch --all#阶段文件git添加git --no-pager diff -R origin/master --numstat#撤消他们git重置 

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?

解决方案

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

这篇关于从现有项目创建一个git repo,并运行`git diff`.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆