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.
Related
I have a git repository on an internal server and now want to have a scheduled task that automatically pulls changes to my local version. Found the GitPython package, which seems to be exactly what I need, but can't get it to work due to the password protection of the repo.
I have already cloned the repo to my local path (git clone git#LOCAL_IP:/repo/MY_GIT.git .) and will get prompted for the password every time I execute git pull from the command line (fair enough). According to How can I call 'git pull' from within Python?, I then tried exactly this
import git
g = git.cmd.Git(MY_LOCAL_PATH)
g.pull()
and (of course) get an error:
...
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
cmdline: git pull
stderr: 'Permission denied, please try again.
Permission denied, please try again.
...
Unfortunately, from the many answers around the web dealing with PythoGit, I found none that tells me how I can set the password (I know that you should never ever hardcode passwords, but still...).
You can save credentials within git so that every git client can access them and won't ask the user. See How can I save username and password in Git? for details on how to do that.
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.
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.
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>
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>