luiserebii / git-identity Goto Github PK
View Code? Open in Web Editor NEW:trident: A command line tool allowing for easy shifting between git identities (username, email, and GPG).
License: MIT License
:trident: A command line tool allowing for easy shifting between git identities (username, email, and GPG).
License: MIT License
The tests, at the moment, test for the following:
However, things such as getting or setting identities aren't. As git is a tool that exists on a "global scope", tests are required to test on an isolated instance of git. I'm not 100% sure how this is accomplished, which is why this piece, unfortunately, must be tested manually, which is technically a bit of a risk to do on personal setups.
The following functions:
shiftIdentity()
shiftIdentityLocal()
getIdentityGlobal()
getIdentityLocal()
setIdentityGlobal()
setIdentityLocal()
are thus untested.
If anyone knows how to accomplish this, kindly post below, or make a PR ๐
Often, a user might quickly clone a certain repo and want to make a minor commit and push; doing this can often result in the user forgetting to switch identities, end up making some sort of mistaken push, and, go through the effort of correcting it and force-pushing, which is bad practice.
I suggest the following syntax:
git-identity clone -i [id-name] [repo-link]
In order to keep complete compatibility with git clone
, we will also need to pass down all the flags git clone
can take. Since -s
is already reserved, we will need to use a different flag; I think -i | --id
can work great, which is essentially a functional alias of -s | --set
.
The ability to rewrite previous authors is not a rare need, and being able to do this easily within the tool would improve its utility. This shouldn't be too difficult to implement, as the bash script to do this is already written:
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
courtesy of GitHub: https://help.github.com/en/articles/changing-author-info
This does not include, however, times where the emails might match with two different identities/GPG keys, at which point, it would be needed to check names and GPG keys (if possible) as well.
There should be two ways to do this, one agnostic, one not. For example, if a user might want to target a git-identity added and switch to a git-identity also recorded, it could look something like:
git-identity revise --from [IDToChange] --to [IDToChange]
Agnostic:
git-identity revise --from-name [name] --from-email [email] --to-name [name] --to-email [email]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.