Skip to content

Instantly share code, notes, and snippets.

@mcmatrix
Forked from CristinaSolana/gist:1885435
Last active September 17, 2019 14:05
Show Gist options
  • Save mcmatrix/c19d3dd3a92d7a32f0eae4619663736e to your computer and use it in GitHub Desktop.
Save mcmatrix/c19d3dd3a92d7a32f0eae4619663736e to your computer and use it in GitHub Desktop.
Keeping a fork up to date
1. Clone your fork:
git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git
2. Add remote from original repository in your forked repository:
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
3. Updating your fork from original repo to keep up with their changes:
git pull upstream master
4. Replay your commits on top of the new commits from the destination branch so that the merge can be a ‘fast-forward’.
git rebase master
5. Update from remote.
git pull
6. Checkout from fork
git remote add theirusername https://github.com/theirusername/reponame
git fetch theirusername
git checkout theirusername/theirbranch
or create new branch mynamefortheirbranch
git checkout -b mynamefortheirbranch theirusername/theirbranch
7. Squashing Git Commits into one
git checkout master
git merge --squash bugfix
git commit
or
git commit --signoff
or
git checkout master && git pull
git merge feature_branch
git reset origin/master
git add . --all
git commit
8. Set permissions to file

According to official documentation, you can set or remove the "executable" flag on any tracked file using update-index sub-command. To set the flag, use following command:

git update-index --chmod=+x path/to/file

To remove it, use:

git update-index --chmod=-x path/to/file

Starting with Git 2.9, you can stage a file AND set the flag in one command:

git add --chmod=+x path/to/file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment