3

Suppose I clone from the linux git repository with --depth 1:

git clone --depth 1 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 

Several days pass so new commits are available upstream, so I want to get these changes by doing git pull, however doing so makes it fetch the entire commit history which I verified by doing git log, the last commit is indeed the first commit of the entire repository.

I do not need the entire history of the project, I simply want only the new data from the initial shallow clone up to the time of pull.

So I try git pull --depth 1 instead, only to get a merge conflict which obviously shouldn't be there because I did not modify the repository locally.

I really think that what I am wanting to do should be possible and already implemented in Git, but I'm just doing it wrong. What is the correct way to do this?

1 Answer 1

1

I believe what I want is

git checkout master git fetch --depth 1 git reset --hard origin/master 

I'm still relatively inexperienced with Git, hopefully someone more experienced can verify this for me.

Sign up to request clarification or add additional context in comments.

1 Comment

BEWARE this would erase local changes. (Of course that's what hard reset does but my mind was off when i copy pasted this)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.