Github issues

I’m having some issues with synchronizing my git repo that I’ve cloned to the version Jeremy is updating. My issue that I’m having is that since I am editing it to run my own notebook off of Jeremy’s I am having a tough time updating to get changes that have been made. Am I not doing this correctly (should I be copying it into a different notebook instead?) or am I missing something major with how git works. I guess what I’m looking for is more just what is everybody else doing.

My process has been:

  1. Clone the fastai github repo git clone
  2. Edit the Lesson files and run my own version using the notebook Jeremy is working with
  3. Do a git pull to grab new changes that Jeremy may have made throughout the week
  4. Usually flounder and try to just get Jeremy’s version back and get rid of my code git reset --hard
1 Like


What I do is to create copy of Jeremy’s notebook and then play with that version.

In that case i can do gitl pull any time to get changes. Since the copy of files are untracked by git.

But in long term you should version control your changes may be in different branch.


Great question. Definitely copy it into a new notebook. Give the new notebook a name that starts with ‘tmp’ (which hides it from this git repo).


Ok, I knew I was probably doing something wrong because the problem is when it’s a jupyter notebook, you can’t just merge it because of the extra stuff being generated behind the scenes. Thanks for the help.

You can also fork the fastai repo (which will show up as<your-user-name>/fastai.git) and add the original as an upstream using git remote add upstream <fastai repo>.

This way your fork points to the main fastai repo and you can sync changes later on. I don’t know if forks are a great way to do git or not, but this has so far worked for me to get the updates. You can follow these steps:

  • Fork the main repo.
  • git clone <fork> and start working off of that.
    – Push any local changes to your own fork: git push -u origin master
  • git remote add upstream
  • Whenever you want to sync your fork with the upstream updates, do:
    git fetch upstream
    git merge upstream/master

You can further refer to this and this for more clarity. :slight_smile:


@A_TF57, I have tried numerous times to follow the steps above for forking the fastai repo. I have origin and upstream set up as follows:


I am able to merge the upstream with my local master. However, when I try to push to ‘origin’, I keep getting authentication errors. It tells me my username or password is not correct. I’m using ‘travisdickey’ as username and the same password I use to log on to GitHub.

Am I doing something wrong? Have you had any trouble with this since you posted this comment? Do I need some sort of special permission from the Fastai repo to push to a forked copy of it? Or is this more likely a GitHub issue? Any advice would be much appreciated.

I’ve never had that error before. You shouldn’t require anything from fastai for push ops to forks. This is likely a GitHub issue.

This link talks about related issues. Is this what you’ve been getting as well? I like the second answer on 2FA, although I haven’t tried it personally on my setup. Let me know if you’re able to resolve it.

Thanks for your help. The problem was caused by two-factor authentication. When I turned that off, I was able to push with no problem.

1 Like

I just ran into this problem today. With the release of v1 I thought I would update using git pull, but of course that led to merge conflicts because I had modified three lesson notebooks. Reading the above, I now know to copy the notebooks before I change them. However, in the mean time, I tried to use emerge, but for some reason the a command only worked on around half of the changes. These were very minor changes, mostly dealing with the number of times a cell was executed, yet a would not work to accept the A version. As a result, I had to constantly switch to edit mode, edit to accept changes, then switch back to fast mode, use a for the next change, then back to edit, etc. With over 50 such changes per file, I finally gave up and just added all of my changed notebooks.

Any advice on how to use emerge and why a doesn’t work all the time? I cannot find any help online for this so far. The emerge docs don’t really mention a workaround.

Hi @toddrjohnson,

I don’t know if this a good approach to you but you can create a script to update your repository for you on the master branch while you work on your branch.

Just as example:
you can make the following assuming you are working in your branch, and in a LINUX machine:

1-Here I ask for the last HASH commit from the LOCAL master branch

echo $(git log master -n 1 --pretty=%H)

2-Here I ask to receive the news from the origin/master this does not merge anything, but let any new code it in standby on memory:

git fetch

3-Here I ask the last HASH commit from the REMOTE origin/master branch to compare the hash later:

echo $(git log origin/master -n 1 --pretty=%H)

4-Now the comparison:

  • If the numbers aren’t different then you don’t need to worry because your local master and remote origin/master are in sync,
  • If the number are different, jump to the master branch don’t forgetting to commit any un-commited at first and merge the new code in standby:

git checkout master
git merge FETCH_HEAD

This will merge all the new code received that was in standby.
Now just using git diff "custom branch" "master branch" to differentiate the local custom branch to the local updated master branch.

Now its up to you how you like to do that.

I prefer create a separated branch to my work, and every time I need to merge something I create a new temporary branch FROM my custom branch for the sake of the merging so I let apart and safe the master and the custom branches and use the temporary branch as a table to merge things.
After merging successfully it will be already prepared to merge with my custom branch because my temp branch was based in mine custom branch.
That way I can leave the master untouched and accumulating changes from the remote source.

You can put all this thing on a shell script easily :

#!/bin/bash -e

cd "your fast ai folder"

GITLOG_LOCAL=$(git log master -n 1 --pretty=%H)
git fetch
GITLOG_REMOTE=$(git log origin/master -n 1 --pretty=%H)

if [[ "$GITLOG_LOCAL" != "$GITLOG_REMOTE" ]];then
     git checkout master
     git merge FETCH_HEAD

Every time I execute this piece of code I just update the master branch on my computer comparing first if it has something new before that. Then I can make decisions if I can merge things unmerged there or if I stash it first … You can use this code and modify it.

Other interesting thing is comparing. Once I am on the temporary branch (based in my custom branch) I can compare just how much commits rest to my temporary branch get updated to the master branch by:

git log ..FETCH_HEAD

So I can check each commit individually and individually pick each one to merge:

git cherry-pick "commit-hash"

As I said once I check everything and picked the interested commits i can just merge all this definitely to my custom branch.

I hope my process can give you some new ideias.

1 Like

If you don’t do that, you can always get back your own version if there’s a conflict without:

git checkout --ours name.ipynb
1 Like

A post was split to a new topic: Git best practices