Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

git squash branch

# Assuming you were branching from the master,
# you don't need to enter yourBranch into the reset step all the time:
git checkout yourBranch
git reset --soft HEAD~$(git rev-list --count HEAD ^master)
git add -A
git commit -m "one commit on yourBranch"

# Explanation:

git rev-list --count HEAD ^master counts the commits since you made your feature branch from the master, f.ex. 20.
git reset --soft HEAD~20 will make a soft reset of the last 20 commits. This leaves your changes in the files, but removes the commits.

#Usage:
# In my .bash_profile I have added an alias for gisquash to do this with one command:

# squash all commits into one
alias gisquash='git reset --soft HEAD~$(git rev-list --count HEAD ^master)'
#After reseting and committing you need to do a
git push --force
Comment

git squash branch

# Assuming you were branching from the master,
# you don't need to enter yourBranch into the reset step all the time:
git checkout yourBranch
git reset --soft HEAD~$(git rev-list --count HEAD ^master)
git add -A
git commit -m "one commit on yourBranch"

# Explanation:

git rev-list --count HEAD ^master counts the commits since you made your feature branch from the master, f.ex. 20.
git reset --soft HEAD~20 will make a soft reset of the last 20 commits. This leaves your changes in the files, but removes the commits.

#Usage:
# In my .bash_profile I have added an alias for gisquash to do this with one command:

# squash all commits into one
alias gisquash='git reset --soft HEAD~$(git rev-list --count HEAD ^master)'
#After reseting and committing you need to do a
git push --force
Comment

PREVIOUS NEXT
Code Example
Shell :: How to install inkscape on Ubuntu 
Shell :: linux unpack .tar 
Shell :: git force add 
Shell :: cmd unzip windows 
Shell :: kde vs gnome vs xfce 
Shell :: show services linux 
Shell :: instal ng2 order pipe 
Shell :: Package signatures do not match previously installed version; ignoring! 
Shell :: pipi ungrade 
Shell :: install vault 
Shell :: zfs check compression type 
Shell :: use file connect ssh 
Shell :: gitignore folder 
Shell :: linux create user with homedir 
Shell :: git reset a single file to previous commit 
Shell :: CocoaPods could not find compatible versions for pod "razorpay_flutter" when running pod install 
Shell :: command line windows find file 
Shell :: bash iterate over a variable range of numbers 
Shell :: why gitignore does not work 
Shell :: ERROR: No matching distribution found for torch.fx 
Shell :: what is a nuget package 
Shell :: debian install docker 
Shell :: grep search 
Shell :: docker command to login with user name and pass word 
Shell :: linux send syslog message to remote server 
Shell :: permissions do not allow pasting files in this directory 
Shell :: git list files with size 
Shell :: ubuntu bluetooth microphone not working 
Shell :: removing portion of history from terminal mac 
Shell :: windows to linux ssh without password 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =