Let's say you want to get the paths of all files changed in your branch compared to the target branch.
git diff --name-only master
Let's say you have a branch off of master, and you want to squash all the commits into one before pushing to the remote.
Run the following (after checking out your branch locally):
git reset --soft `git merge-base master HEAD`
git commit -m 'One big commit'
This will get rid of branches that have been merged that aren't master, main, or develop.
git branch --merged | egrep -v "(^ \* |master|main|develop)" | xargs git branch -D
This is how to set up a remote git repository (a mirror) simply via ssh.
It assumes you have a server set up with SSH, and that you have sudo access to it.
git
user (sudo adduser git
)./var/repos/git
owned by the git
user.git
user's .ssh/authorized_keys
file, so you can SSH as that user.myrepo
, create a directory /var/repos/git/myrepo.git
owned by the git
user.git
user, in that new directory, run git init --bare
.git add remote myremotename git@myserver:/var/repos/git/myrepo.git
git push -u myremotename main
(or whatever your main branch is)There, now you have a remote mirror on a server you control.