0

I made a local repository, got connected to remote repository using git remote add origin, and now I want to pull in my local repository only the previous commit done to the remote repository. How should I proceed?

mahinlma
  • 1,208
  • 3
  • 11
  • 24
  • 2
    Have you checked out any of the remote branches locally? Until this is done (or you otherwise map remote tracking references to local branches) you need to specify remote and local branches in `git pull`. (Doing a `git fetch` should still work to populate the remote tracking branches.) – Richard Jan 03 '19 at 10:23
  • 1
    maybe ssh-key missing in remote repo? Can you share what have you tried, errors raised? – Aaron_ab Jan 03 '19 at 11:23

1 Answers1

0

First of all,

git fetch

Let's say for example in total you have two commits in remote:

git log

will show all of your commits

commit 7900b19652cdlaociemcage626554ded33e9cfa8 (HEAD -> master, origin/master, origin/HEAD)
Author: ayush <ayush@domain.com>
Date:   Wed Jan 2 17:03:28 2019 +0545

    second commit

commit 32454eeajkdnkadnlk5a5djkaad7e01f09102180
Author: ayush <ayush@domain.com>
Date:   Tue Jan 1 14:52:06 2019 +0545

    first commit

Now if I understand correct, You want to pull everything upto first commit in your local branch, right?

git checkout 32454ee

this will take you to first commit in local branch. Use the starting 7 characters of any commit hash.

sparsh
  • 1,438
  • 1
  • 15
  • 34