Git merge-base and merge-tree in python - python

I am working on a python script to automatically sync my workspace if possible and need to judge if I can rebase my changes on top of remote master changes.
I am trying to use the brilliant answer here : https://stackoverflow.com/a/6283843/965830
I want to run the following commands :
Fetch the remote to your repository. For example: git fetch origin master
Run git merge-base: git merge-base FETCH_HEAD master
Run git merge-tree: git merge-tree mergebase master FETCH_HEAD (mergebase is the hexadecimal id that merge-base printed in the previous step)
For command 1, I am using the following successfully
gitRepo = git.Repo(abspath);
gitRepo.remotes.origin.fetch(refspec="master")
However, I am not able to find any documentation for merge-base and merge-tree commands.
------Edit
Found this documentation of merge-tree : https://gitpython.readthedocs.io/en/stable/reference.html?highlight=merge-tree#git.index.base.IndexFile.merge_tree
How can I write this in a way that it doesn't actually perform the merge.

Related

How to see change on remote repo, which not in local repo?

I'm executing a command 'git push' and get error.
My remote repository is ahead of the local one.
I want to find out what changes have occurred on the remote repository.
Assuming you don't want to pull those changes yet, you can accomplish this with git log. First run git fetch to update your local refs. Then you'll want to run git log my-branch..origin/my-branch. This will show you commits on origin/my-branch (i.e. remote), which do not exist in your local repository.

Is Heroku blocking my local git commands?

So i've run a heroku create command on my django repo, and currently it is living on Heroku. What I didnt do prior was create my own local git repo. I run git init, create a .gitignore to filter out my pycharm ide files, all the fun stuff.
I go to run git add . to add everything to the initial commit. Odd...it returns:
[1] 4270 killed git add.
So i run git add . again and get back this:
fatal: Unable to create /Users/thefromanguard/thefromanguard/app/.git/index.lock': File exists.
"Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue."
So I go and destroy the file, run it again; same error. Removed the whole repo, repeated the process, still got the same message.
Is Heroku running in the background where ps can't see it?
I would start over.
Destroy the heroku app
heroku apps:destroy --app YOURAPPNAME
Remove the whole repo (I would even remove the directory)
Create new directory, copy files over (do NOT copy old git repo artifacts that may be left over, anything starting with .git)
Initialize your git repo, add files, and commit, then push upstream to your remote (like github, if you're using one) git init && git add . && git commit -m 'initial commit' and optionally git push origin master
Then perform the heroku create
That should remove the conflict.

upload via git: fatal: '/git/p/Boggle' does not appear to be a git repository

I am doing the reddit pygame boggle challenge. On my laptop it is in a directory called Boggler, but at sourceforge it is called pygame-boggle. When I do 'git push -u origin master' it gives the error in the title. What am I doing wrong? How do I get it to push?
I followed the instructions here: https://sourceforge.net/p/pygame-boggle/code/ref/master/
Have you initialized the repo? It seems like you haven't.
Run the command git init to set up a git repo. Then, add a remote to your repo (wherever it may be, github or bitbucket or any other site) by running the command
git remote add <url to remote here>

Create a branch on a remote repository with pygit2

I am using pygit2 to create a branch on a remote repository.
If it was in a local repository i would've used :
repo=pygit2.Repository(repo_url)
repo.create_branch('branch1', repo.head.get_object(), force=False)
But when i give the function Repository a remote url (not a path) it doesn't work, is there a solution ?
You will have to create your branch locally and then push it to the remote.
Once its pushed you can add remote with the branch name to track it locally (required on older git versions prior to 1.9).
The push command is here.
git push --set-upstream <remote> <branch>

hg mercurial - how to merge in 3 way merge window in shell

I have less experience with mercurial. i am having this problem:
I push everytime from my windows pc in tortoiseHG-Workbench to repo. works fine.
I pull to my server from repo with hg pull .... works fine.
then it asks me to run hg update. i will do it. but then it says, there is something to merge in my views.py and automatically opens a 3-way merge window in shell. I am using ssh tunnel - PuTTy.
in this 3way merge window, no hg commands are available. what i always do is:
> views.py #emptying the file
then i copy paste the views.py from my local pc to server and save it.
this works. but thru this, there will be always conflict because i am changing the same views.py in both sides. how do i solve this so that i dont have to merge everytime? i desperately need some help!
the problem is, there is no hg commands available in 3-way merge window
If you don't have any differences between your production and development script that should be merged, it is safe to always do update clean with update -C. This will replace all local changes you made with the latest version that you pulled from the repository. So the workflow would be:
hg pull
hg update -C

Categories

Resources