Tommy Bravo
Tommy Bravo

Reputation: 532

Is there a way to compare local [non-git] file tree directly to a remote git repo using a git/console command?

So my local file tree is just a file tree no git repo.

I was wondering if there is an easy way to compare the full directory to a remote git repo while not creating a git repository in the local directory/machine?

'Easy' means no copying full folder trees over a clone here. As that's the only solution I could think of already, but that seems like a drag for something like this.

Upvotes: 0

Views: 202

Answers (1)

LinFelix
LinFelix

Reputation: 1076

Actually, there is a solution:

for i in $(find -type f );
do
diff $i <(curl -s https://raw.githubusercontent.com/<user_name>/<repo_name>/master/$(echo $i | cut -c 3-))
done

This command will compare your local files with the GitHub repository <user_name>/<repo_name>.

For Gitlab

for i in $(find -type f );
do
diff $i <(curl -s https://<gitlab_instance>/<project_name>/<repo_name>/raw/master/.gitlab/$(echo $i | cut -c 3-))
done

This command will compare your local files with the <project_name>/<repo_name>.

If you are using a private repo then you can modify the curl command accordingly and give if your access token or a password. For more information see Curl

Upvotes: 1

Related Questions