我现在开始和Git玩了,我有点困惑.对我来说,看起来有很多选择可以做同样的事情.我现在的问题是以下命令之间的区别是什么:
还有哪一个更适用于更新远程分支的本地副本?
我正在尝试建立一个git存储库的darcs镜像.我有一些工作正常,但有一个重大问题:如果我将一大堆提交推送到git repo,那些提交将合并到一个darcs补丁集中.我真的想确保每个git commit都设置为单个darcs补丁集.我敢打赌这可能是通过某种方式git fetch跟踪审查远程分支的本地副本,但我的git fu不能胜任这项工作.
这是我现在使用的(ksh)代码,或多或少:
git pull -v # pulls all the commits from remote --- bad!
# gets information about only the last commit pulled -- bad!
author="$(git log HEAD^..HEAD --pretty=format:"%an <%ae>")"
logfile=$(mktemp)
git log HEAD^..HEAD --pretty=format:"%s%n%b%n" > $logfile
# add all new files to darcs and record a patchset. this part is OK
darcs add -q --umask=0002 -r .
darcs record -a -A "$author" --logfile="$logfile"
darcs push -a
rm -f $logfile
Run Code Online (Sandbox Code Playgroud)
我的想法是
git fetch …假设我已经从c:\中完成了以下操作,从远程来源获取最新代码的正确方法是什么?
# Create repo...
mkdir Test
cd Test
git init
...create files
git add .
git commit -a -m "Init Commit"
# Clone repo...
cd ..
git clone Test TestClone
# Edit original
cd Test
...edit files
git commit -a -m "Init Edit"
# Go back to Clone
cd ..\TestClone
# Get latest code
# Now what??? pull or update then pull
Run Code Online (Sandbox Code Playgroud)