Git Branch Management, Fixing Large files errors
In your Github fork, you need to keep your master branch clean, by clean I mean without any changes, like that you can create at any time a branch from your master. Each time that you want to commit a bug or a feature, you need to create a branch for it, which will be a copy of your master branch.
When you do a pull request on a branch, you can continue to work on another branch and make another pull request on this other branch.
Before creating a new branch, pull the changes from upstream. Your master needs to be up to date.
$ git pull
Create the branch on your local machine and switch in this branch :
$ git checkout -b [name_of_your_new_branch]
Push the branch on github :
$ git push origin [name_of_your_new_branch]
When you want to commit something in your branch, be sure to be in your branch. Add -u parameter to set-upstream.
You can see all the branches created by using :
$ git branch -a
Which will show :
* approval_messages
master
master_clean
Add a new remote for your branch :
$ git remote add [name_of_your_remote] [name_of_your_new_branch]
Push changes from your commit into your branch :
$ git push [name_of_your_new_remote] [url]
Update your branch when the original branch from official repository has been updated :
$ git fetch [name_of_your_remote]
Then you need to apply to merge changes if your branch is derivated from develop you need to do :
$ git merge [name_of_your_remote]/develop
Delete a branch on your local filesystem :
$ git branch -d [name_of_your_new_branch]
To force the deletion of local branch on your filesystem :
$ git branch -D [name_of_your_new_branch]
Delete the branch on github :
$ git push origin :[name_of_your_new_branch]
The only difference is the: to say delete, you can do it too by using GitHub interface to remove branch: https://help.github.com/articles/deleting-unused-branches.
If you want to change default branch, it’s so easy with GitHub, in your fork go into Admin and in the drop-down list default branch choose what you want.
If you want create a new branch:
$ git branch <name_of_your_new_branch>
— — — — — — — — — — — —
Fixing Git error “GH001: Large files detected”
When you get errors such as ->remote: error: GH001: Large files detected. You may want to try Git Large File Storage — https://git-lfs.github.com.remote: error: Trace: f7c3c21d608c253f334ca22d52582393
The problem is that you can’t simply remove the file because it is tracked inside the previous commits so you have to remove this file completely from my repo.
Execute following command to fix the issue ->
$ git filter-branch -f — index-filter ‘git rm -r — cached — ignore-unmatch file_or_dir_name’
At which point you can push the file to GitHub.
— — — — — — —
You could git fetch origin to update the remote branch in your repository to point to the latest version.
For a diff against the remote:
git diff origin/master
Yes, you can use caret notation as well. If you want to accept the remote changes:
git merge origin/master
Hope you like the tutorial. Please let me know your feedback in the response section.
Happy learning!