Here's how to list the commits that happened between two tags.
git log --pretty=oneline 0.8.0...0.9.0
The two tags—in this case, 0.8.0
and 0.9.0
—need to exist.
You can list existing tags in a repository as below.
git tag
Here's how to remove a remote Git branch without using an app or a website user interface, say, GitHub or GitLab.
# Delete a remote Git Branch (assuming your remote is called origin)
git push origin --delete your-branch-name
# To bitbucket.org:nonoesp/some-repo.git
# - [deleted] your-branch-name
Remember that you will also have to delete the Git branch from your local repository as follows.
# Delete a local branch
# -d is a shorthand for --delete
git branch -d your-branch-name
# Deleted branch your-branch-name (was f9b622c).
# Force delete a local branch (regardless of the branch merge status)
# -D is a shorthand for --delete --force
git branch -D your-branch-name
# Deleted branch your-branch-name (was f9b622c).
Here's how to remove a local Git branch.
# Delete a local branch
# -d is a shorthand for --delete
git branch -d your-branch-name
# Deleted branch your-branch-name (was f9b622c).
# Force delete a local branch (regardless of the branch merge status)
# -D is a shorthand for --delete --force
git branch -D your-branch-name
# Deleted branch your-branch-name (was f9b622c).
Remember that you will also have to delete the Git branch from your remote repository as a separate step.
Here's how to remove a remote Git branch without using an app or a website user interface, say, GitHub or GitLab.
# Delete a remote Git Branch (assuming your remote is called origin)
git push origin --delete your-branch-name
# To bitbucket.org:nonoesp/some-repo.git
# - [deleted] your-branch-name
I was getting this error when trying to git add
and git commit
code changes in my repository.
fatal: Unable to create '.git/index.lock': File exists.
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
Simply removing the .git/index.lock
file made everything go back to normal.
rm .git/index.lock
Nothing broke and I could immediately add and commit new files.
cd /path/to/repo.git
sudo chgrp -R {groupname} .
sudo chmod -R g+rwX .
find . -type d -exec chmod g+s '{}' +
Let say you stage all your Git changes and then commit them.
git add --all
git commit -m "Edit REDME.md"
There's a typo on REDME
— should read README
— and we want to "amend" this error.
git commit --amend
The commit --amend
command lets you edit the commit message in the vim
editor.
You can also change the message by specifying the new message in the command line with the -m
argument.
git commit --amend -m "Edit README.md"
As the commit message is part of the commit itself, editing the message alters the commit hash, which means that if you've already pushed a commit to a remote, the remote won't let you push the new edit directly. But you can force that to happen.
git push --force branch-name
# Get name of Git's current branch and push changes to origin
git push origin $(git branch | grep \* | cut -d ' ' -f2)
I use a text expander to expand gpp
to this command whenever I'm on Terminal. Instead of expanding to git push origin master
this command will push to whatever branch you are in.
# Get name of Git's current branch
git branch | grep \* | cut -d ' ' -f2
open $(git remote get-url origin)
Note that this will only work when the Git repository has been cloned via HTTPS and not SSH.
You can set Git to assume certain files haven't changed even when they have (without adding them to your .gitignore
file). This way, it won't track changes to make to one (or multiple) files.
git update-index --assume-unchanged file
After this command is run, the repository continues tracking the file. It might have changes that git will want to commit.
git update-index --no-assume-unchanged file
--assume-unchanged
In case you made changes while --assume-unchanged
was on and don't want to keep the changes on the file: Roll-back to where the repository is when you want to pull or push changes.
git checkout -- file