git commit --amend
, this will update the previous commit with your new changes. There is no point in having a bunch of commits that just called "fixes", use amend instead!git config --global pull.ff only
If you need to force push then always use --force-with-lease
(this is more secure than --force
).
Use git status
often so that you know whats going on.
If you are on Windows check out Git on Windows.
First checkout the branch you want to base your feature branch on
Then create your new branch:
git checkout -b name-of-feature-branch
git push -u origin head
If you have a lot of commits that you want to squash in your feature branch.
Let's say your development branch is called dev
, then you can run:
git reset --soft $(git merge-base origin/dev head)
git commit
git push --force-with-lease
WARNING
Never use git pull
in your own feature branch, its far to easy to screw up your branch this way.
Often you'll need to keep your feature branch up to date with new changes. You should do this often to avoid as many merge conflicts as possible. If you have a lot of commits then it may be helpful to squash stuff first before updating your branch (see above).
Let's say your development branch is called dev
, then you can run:
git fetch
git rebase origin/dev
git push --force-with-lease
git fetch
git rebase -i origin/dev
If you need to move some stuff over to its own PR you can:
Go to your development branch (ex. git checkout dev && git pull
)
Create a new feature branch
Copy inividual files or folder over from your other branch:
git checkout old-branch-name src/file-or-folder