While working on an AI-related app recently using vectors, I found myself with a 115MB file in my repository. While attempting to push to GitHub, I got an error in GitKraken about a hook failing. I didn’t have any hooks locally or remotely, so the issue was a bit perplexing. After trying a few things, I resorted to command-line Git, and that’s when I saw the problem.
GitHub blocks files larger than 100 megabytes. They recommend using Git Large File Storage, but I decided maybe I shouldn’t be adding large vector files into my repository anyway.
As developers, we often find ourselves forking open-source projects on GitHub to contribute or to modify for our specific needs. While creating a fork is a simple process, keeping it up-to-date with the original repository can sometimes be confusing. In this blog post, we will explore the steps required to keep your GitHub fork updated with the latest changes from the upstream repository.
Step 1: Configure the Upstream Repository To keep your fork updated, you must first configure the upstream repository – the original project from which you created your fork. This ensures you can easily fetch the latest changes from the upstream repository.
I recently worked with GitHub Actions, where I generated a JSON file and then needed to add it to the repository. I parsed some Markdown files and then dynamically created a manifest JSON file of them, committing it into the repo every time a push was made.
I hit a permissions roadblock I embarrassingly spent over an hour solving, and I hope you don’t make the same mistake.
name: Build Blog JSON on: push: paths: - 'blog-posts/\*\*/\*.md' jobs: build: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - name: Get list of Markdown files run: | cd blog-posts files=($(ls \*.md)) json\_array=() for file in "${files[@]}" do date\_string=$(grep -E '^date: ' "$file" | cut -d' ' -f2) # Use the date command to extract the year, month, and date year=$(date -d "$date\_string" +%Y) month=$(date -d "$date\_string" +%m) day=$(date -d "$date\_string" +%d) json\_array+=($(echo "{\\"file\\":\\"$file\\",\\"date\\":\\"$date\_string\\",\\"year\\":\\"$year\\",\\"month\\":\\"$month\\",\\"day\\":\\"$day\\"}")) done echo "[$(IFS=,; echo "${json\_array[\*]}" | jq -s -c 'sort\_by(.date)')]" > ../static/blog.json - name: Remove trailing comma run: | sed -i '$ s/,$//' static/blog.json - name: Commit changes run: | git config --global user.email "no-reply@github.com" git config --global user.name "GitHub Actions" git add static/blog.json git commit -m "Update blog.json" git remote set-url origin https://x-access-token:${{ secrets.GITHUB\_TOKEN }}@github.com/${{ github.repository }} git push env: GITHUB\_TOKEN: ${{ secrets.GITHUB\_TOKEN }} Now, the important part of my action is the Commit changes action. You need to supply an email and name for the committer. In this instance, I just made up something generic. The first important line is setting the origin URL. We are referencing some variables GitHub creates for us automatically. Notably, GITHUB_TOKEN and repository.
You fork a repository on somewhere like GitHub or GitLab and you make some changes. Maybe you want to contribute to an open-source repository. You work on your fork, but in the interim, the repository you forked has had a new release and quite a few new commits.
How do you get those commits from the repository you forked and merge them into your fork? This is where setting an upstream from the forked repository comes in handy.
I recently encountered an error in GitKraken after a bad merge occurred when trying to merge in some changes from the main development branch, whilst I had quite a few local changes that GitKraken usually automatically stashes for me.
My problem was I was using Bash Ubuntu on Windows, which has a nasty habit of locking files. The merge and stashing seemed to fail because in the changes I was attempting to merge in, some files were deleted.
I tried closing and reopening GitKraken, but it was clear that GitKraken wasn’t going to let me open up that repo again.
I used to use Diffmerge for my merge/comparison needs, however I find the outdated interface to be unfriendly and ugly to look at.
On Windows I use Sourcetree and Beyond Compare works without integration, it shows up in the appropriate dropdowns but on Mac it does not. I don’t understand why Sourcetree on Mac is different to Windows, but anyway.
Fortunately, Sourcetree makes it easy to use third party comparison tools even if they are not in the dropdowns.