If you need to quickly set the user and email address for a single git repo, you can do this:
git config user.email firstname.lastname@example.org
git config user.name "John Doe"
If you want to modify the .git/config file directly, you can add in this block:
name = John Doe
email = email@example.com
git config --global user.email firstname.lastname@example.org
git config --global user.name "John Doe"
In this previous post I wrote about how to get some git branch information into your shell. That was written back when Ubuntu 12 LTS was the standard.
I recently upgraded a box to Ubuntu 16 LTS, and this information went away. 🙁
I discovered via trial and error, that the call that’s needed in .bashrc is now:
## To show you what branch you are in as you move around git repos
if [ -f /etc/bash_completion.d/git-prompt ]; then
PS1='\[\u@\h \e[33m\]\w\[\e[0m\] $(__git_ps1 " (%s)")\n\$ '
/etc/bash_completion.d/git is now: /etc/bash_completion.d/git-prompt
Say you are working on not your normal computer and are working on a branch that isn’t quite ready to get merged with the official git repo for the codebase. Here’s what you can do:
git push SOME_OTHER_ORIGIN branch_name –tags –set-upstream
Then, when you get back to the computer you normally work on, you can do this:
git fetch SOME_OTHER_ORIGIN
git checkout -b branch_name
# which will switch you to that branch
$ git fetch SOME_OTHER_ORIGIN branch_name
Password for ‘https://email@example.com’:
* branch branch_name -> FETCH_HEAD
# Check this is what you want:
$ git log ..FETCH_HEAD
# if it is, then
$ git merge –no-ff FETCH_HEAD | more
NOTE: You might need to hide some local files that get gotten in the 1st place.
Sometimes a script will upgrade/add/modify/delete a large swath of files (possibly due to an upgrade-type script). If you are lazy, then you’ll want a script to help you commit those files. Here’s what I’ve come up with:
To perform a git add to all modified files:
for file in `git status | grep modified | cut -d ":" -f 2`; do git add $file; done
To perform a git rm to all modified files:
for file in `git status | grep deleted | cut -d ":" -f 2`; do git rm $file; done