Create a branch on a remote repository with pygit2 - python

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>

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.

Git merge-base and merge-tree in 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.

Deploy to my server with Git

I have a development of a django project on my day-to-day laptop. Now I have put together a server with Ubuntu, nginx, gunicorn with postgreSQL.
I have pip't git on both my laptop and server. And done a 'git init' in my project on the laptop.
Now I am trying to push/deploy this on my local server.
I have done tons of commands that, more or less, look like this
git push --set-upstream ssh://admin#192.168.1.240/home/admin/Django/ master
Do not think I have to say that I am new to all this exciting stuff. It is very interesting, but now my head is foggy and I am stuck.
Pointers in right direction are much appreciated! =)
First you have to add and commit to the current local repo. Try 'git add' and 'git commit' for that.
Next, add the remote "server" machine, use "git remote add", such as:
git remote add origin 192.168.1.240:/home/admin/Django
Finally use the 'git push' command to push the local to the remote:
git push origin master

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>

Categories

Resources