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?
Asked
Active
Viewed 58 times
0

mahinlma
- 1,208
- 3
- 11
- 24

ayush srivastava
- 51
- 1
- 4
-
2Have 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
-
1maybe ssh-key missing in remote repo? Can you share what have you tried, errors raised? – Aaron_ab Jan 03 '19 at 11:23
1 Answers
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
-
But if i want to pull from remote an earlier version without comitting any version of myself, then how should i do ? – ayush srivastava Jan 07 '19 at 10:38