开发者

Pulling a remote repository

I'm a fairly new Git user who's only familiar with basic commands. I've cloned a Git repository to a local branch, then used:

git add file.txt
git commit -m 'my message'
git push

So far, this is working fine to commit. Now, I've been asked to pull my changes into the remote repository. Since this is the first time I've ever done this, I want to do so 'safely,' without making any inadve开发者_StackOverflow社区rtent changes to the remote repo. I'd also like to review the commits before pulling them so I'm sure I'm pulling in the right ones.

So, I'll be SSHing into the remote server and pulling the changes I've made in my local repository.

What is the best way to do this?


. I've cloned a Git repository to a local

Assuming you have cloned from your remote repo

Now, I've been asked to pull my changes into the remote repository

well you already did that with

git push

If you want to pull little safely from your remote host do first

git fetch

and later

git merge origin/master

Lastly to check commits you can do

git log


A team of mine when learning git memorized these 4 steps:

  1. ADD ~ git add .
  2. COMMIT ~ git commit -m 'your message'
  3. PULL ~ git pull Merge Conflict? Fix it so the code runs the same way.
  4. PUSH ~ git push

This way, as long as everyone pulls before they push, technically code that doesn't work should never make it live.

Hope this helps :)


If safety is your priority, then backup your work and copy the repository you're going to work on, to a new place, and work on that until you're sure you know what you're doing.

RTFM

check out git help pull (until this gets back up)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜