Skip to content

dzhitomirsky/github-profile-switcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Github prfile switcher

Intro

Sometime you may face the situation when you want to commit under different github profiles/accouts, e.g. at office you use company accout google-john-doe and at home you want to create super-secret projects under your persona github accout john-doe and also you do it all on MACBOOK.

Manual steps

To do the actions described above you need to:

  • drop ~/.git-credentials folder
  • rewrite ~/.gitconfig file like
[user]
        email = {email}
	      name =  {user}

[credential]
        helper = store

[push]
        default = current
  • as far as you use macbook drop github note in keychain

All this stuff is a long stroy...so I introduce a small fency script written ib python 2.7 to do all this for you

How to use

  • clone the repo
git clone https://github.com/dzhitomirsky/github-prfile-switcher
  • add next env variables (potensially you will need sudo mode - so add them to ~/.bashrc and visudo)
HOME_USER 
HOME_EMAIL

WORK_USER 
WORK_EMAIL 

if you want to do it per terminal sessions:

export HOME_USER=super-user
...
  • call the script
#to setup home env
python gitprofile.py home 

#to setup work env
python gitprofile.py work


#work env is used by default
#next line will give the same result as python gitprofile.py work
python gitprofile.py

Setup script to PATH to use from place

  • create ~/bin (if it doesn't exit)
  • add bin folder to PATH (if it isn't so), you can also make it in .bashrc to make it constant
export PATH=$PATH:/home/el/bin
  • copy gitprofile.py to bin
cd github-prfile-switcher
cp gitprofile.py ~/gitprofile
  • make it executable
chmod +x ~/bin/gitprofile
  • Call it in any place
gitprofile work #work profile
gitprofile home #home profile
gitprofile #work profile by default

About

Python script that helps switching between home/work github profiles

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages