Difference between revisions of "Git"
From John Freier
(→Rebase) |
|||
Line 2: | Line 2: | ||
== Rebase == | == Rebase == | ||
When you are on a branch, you get | When you are on a branch, you get | ||
− | git rebase master | + | git rebase master |
+ | You will get conflicts with the remote origin if you try and push. Here are some ways to solve this. | ||
+ | |||
+ | |||
+ | This will force the remote origin to stay up to date with your branch. But be aware, if there are more people working on the feature branch then just you, you may overwrite code. | ||
+ | git push --force origin feature_branch | ||
+ | |||
+ | With force with lease, it will git will warm you if anyone else has committed any code, this helps to prevent overwriting someones code. | ||
+ | git push --force-with-lease | ||
+ | |||
+ | Another good option after rebase with master is to just delete the branch on the remote origin, and then recreate it. | ||
+ | git checkout myFeature | ||
+ | git rebase master | ||
+ | git push origin --delete myFeature | ||
+ | git push origin myFeature | ||
== Squash feature branch == | == Squash feature branch == |
Revision as of 10:00, 3 June 2020
Rebase
When you are on a branch, you get
git rebase master
You will get conflicts with the remote origin if you try and push. Here are some ways to solve this.
This will force the remote origin to stay up to date with your branch. But be aware, if there are more people working on the feature branch then just you, you may overwrite code.
git push --force origin feature_branch
With force with lease, it will git will warm you if anyone else has committed any code, this helps to prevent overwriting someones code.
git push --force-with-lease
Another good option after rebase with master is to just delete the branch on the remote origin, and then recreate it.
git checkout myFeature git rebase master git push origin --delete myFeature git push origin myFeature
Squash feature branch
This squashes all the commits in to one.
git merge --squash feature
and then you need to commit the new squashed changes.
get commit -m "squashed changes merged in."
Squash Commits
This squashes the last 3 commits.
git reset --soft HEAD~3 git commit -m 'new commit message'
View the logs
A another way to view the logs.
git log --oneline --decorate --graph --all