Make Develop your default branch. If you only have a master branch, Create new develop banch. (See create a new branch below) This is where you will work 85% of the time. Only use Master branch for production ready code.
If you add a new feature, go to develop branch and then create a new branch with feature name. (See create a new branch below)
- Once you're done with the new feature, Merge to develop.
- Push to staging server and test (optional).
- If all good on staging serve, switch to master beanch and merge develop branch into master.
- Then switch back to develop branch and delete the new feature branch. (Sometimes you will have merge confilct due to CSS etc.. I use https://www.sublimemerge.com/ free version to fix these issues)
git checkout BranchName
git branch
1. Go back to develop branch
2. git checkout -b NewBranch
3. git commit -m "Init NewBranch"
4. git push origin NewBranch
5. git push --set-upstream origin NewBranch
6. git push
1. git branch (See all branches)
2. git push origin :branchname (Deletes branchname remote from github)
3. git branch -D branchname (Deletes branchname from local)
1. git branch -m current-branch new-branch
2. git push origin :current-branch new-branch
1. Switch from master to new branch
2. Make sure your on new branch IE newbranch
3. git push staging newbranch (Adds branch to /var/repo/dev.git/refs/heads)
4. git push staging +master:refs/heads/newsponsor (swithches branch in /var/repo/dev.git HEAD from master to newbranch)
5. git push staging (adds new changes to dev.example.com website)
1. git fetch origin <branch_name>
1. Fetch the remote branch from the origin first.
2. git fetch origin remote_branch_name
3. Merge the remote branch to the local branch
4. git merge origin/remote_branch_name
Use to clear all your changes to a branch prior to committing.
git reset --hard && git clean -df
//Create a alias
alias nah="git reset --hard && git clean -df"