-
Notifications
You must be signed in to change notification settings - Fork 0
Git
- git rm -r --cached FolderName
- git commit -m "Removed folder from repository"
- git push origin master
- Check status with:
git status
. - If any changes are unstaged, they have to either be staged with
git add
or unstaged withgit stash
. - Perform a git
rebase
, usingfixup
on the commits you want to "merge". The difference betweensquash
andfixup
is that during therebase
, thesquash
operation will prompt you to combine the messages of the original and thesquash
commit
, whereas thefixup
operation will keep the original message and discard the message from thefixup
commit. For instance, if the git history looks like the following:
d1bff072 2019-11-11 | fix: Code clean up (HEAD -> features/peg/peg-784, origin/features/peg/peg-784) [Baltasar Brito]
80918a05 2019-11-11 | fix: Code clean up [Baltasar Brito]
0793184c 2019-11-08 | feat: Change tags logic [Baltasar Brito]
If the end goal is to keep only the Change tags logic
commit but also keep the changes made by the other two, then one could do: git rebase -i HEAD~3
. An interactive rebase. Then, in each of the two to be "joined", fixup is to be chosen.
- Send the changes to the remote branch with:
git push --force-with-lease
.
-
List branches:
git branch -a
. -
Back to original head of the branch, delete all changes until now:
git reset --hard HEAD
.
If the flag--hard
is not used then instead of being deleted, the changes made so far become unstaged. This is useful in case a restructuring of commits is necessary for example. To reset to a specific commit in the history of the branch just write the hash of the commit afterHEAD
or the number of commits to reset. The following command will reset the last two commits and delete them from git history:git reset --hard HEAD ~2
.
- Change base or parent of branch:
git rebase <branch to rebase to>
.-
-i
: interactive, and is used to know which changes will be made beforehand. It can be used like:git rebase -i master
for example.
-
- Remove commit:
drop
. - Use commit:
pick
.
- Send local changes to remote:
git push
. - Override remote with local changes:
git push --force
. - Override remote with local changes if state of remote has not been altered since last check:
git push --force-with-lease
.
- Apply the changes of a commit to another branch. From the branch to be altered (git co to that branch) use
git cherry-pick <commit-hash>
and then push to remote.
- Delete a remote branch.
git push <remote> --delete <branch-name>
,git push origin --delete feature/peg-755-754
is an example.