Needed pull example or help with code
See original GitHub issueHi
Firstly, thanks for good work.
Is there a chance to provide by you PULL example (git fetch followed by git merge FETCH_HEAD) or can you help me how should I change below code to achieve “git merge FETCH_HEAD”?
I used your fetch example and it worked, my repo is in this stage:
“Your branch is behind ‘origin/master’ by 1 commit, and can be fast-forwarded. nothing to commit, working directory clean”
I won’t have any changes in repository in future and don’t have now, so I’m looking for method that won’t create commit and won’t force me to push ‘merge commit’. I was trying to modify your merge-cleanly example, but it creates commit, so it’s not perfect for me (BTW don’t know if this correct, because source tree shows history strange, maybe something with date of commit 1973-11-29)
var repo;
var localReference, ourCommit;
var remoteReference, theirCommit;
var ourSignature = nodegit.Signature.create("user test", "user@test.com", 123456789, 60);
Repository.open("master")
.then(function(repository) {
repo = repository;
return repo.getReference('refs/remotes/origin/master');
}).then(function(reference) {
console.log(reference.target());
remoteReference = reference;
return repo.getReference('refs/heads/master');
}).then(function(reference) {
console.log(reference.target());
localReference = reference;
return repo.getCommit(localReference.target());
}).then(function(commit) {
ourCommit = commit;
return repo.getCommit(remoteReference.target());
}).then(function(commit) {
theirCommit = commit;
return Merge.commits(repo, ourCommit, theirCommit);
}).then(function(index) {
if (!index.hasConflicts()) {
index.write();
return index.writeTreeTo(repo);
}
}).then(function(oid) {
return repo.createCommit('refs/heads/master', ourSignature, ourSignature, 'we merged their commit', oid, [ourCommit, theirCommit]);
})
.done(function(commitId) {
console.log('New Commit: ', commitId);
console.log("It worked!");
},
function() {
console.log("It failed :( !");
});
Thanks
Issue Analytics
- State:
- Created 9 years ago
- Comments:8
Top Results From Across the Web
Git Pull Explained - freeCodeCamp
git pull is a Git command used to update the local version of a repository from a remote. It is one of the...
Read more >Git Pull | Atlassian Git Tutorial
The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match...
Read more >What is a Pull Request? - PagerDuty
A pull request – also referred to as a merge request – is an event that takes place in software development when a...
Read more >About pull requests - GitHub Docs
Pull requests let you tell others about changes you've pushed to a branch in a repository on GitHub. Once a pull request is...
Read more >Best Practices for Reviewing Pull Requests in GitHub - Rewind
6. Reinforce Code Submission Best Practices ... Remember to promote positive actions a code author can take. For example, you could enable support...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So we currently don’t have a method for a traditional CLI pull function. We do however have a convenience method for merging which will do a fast-forward if possible. You could then do something like
That should do what you’re looking for. There are a few other things that’s off with your code but we’re doing support on our Gitter channel which you can swing by and we’ll help you some more if you want.
I’m going to keep this open however until we get a pull example in.
Made a commit for adding an example for pulling with a merge.