Imagine your working on a project on github.com and then you want to move that project over to another git server (imagine its another github server, thats not hosted on github.com, but maybe its your own person github.personal.org for your organization). We need to move all of our commits over from our Repo (which we call here Test1). But we also need to rename our github username, to whatever username we use on our new github server. These steps cover how to do that.

Assuming Test1 is a very simply repo with just one branch.

Get This Info

Name of repo: Test1

FROM or SOURCE:
github.com username: infotinks
github.com email: boss@infotinks.com

TO or DESTINATION:
github.personal.org author name: Koss Bossy
github.personal.org commiter name: Koss Bossy
github.personal.org username: infotinksy
github.personal.org email: infotinksy

Steps

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
### go to repo folder
cd Test1;
git config -l ### list all configs (note the current user.name and user.email, they should be the github.com username and email)
### set new user.name and user.email (to match github.personal.org)
git config user.name "infotinksy";
git config user.email "infotinksy@personal.org"
### go to repo folder cd Test1; git config -l ### list all configs (note the current user.name and user.email, they should be the github.com username and email) ### set new user.name and user.email (to match github.personal.org) git config user.name "infotinksy"; git config user.email "infotinksy@personal.org"
### go to repo folder
cd Test1;
git config -l ### list all configs (note the current user.name and user.email, they should be the github.com username and email)
### set new user.name and user.email (to match github.personal.org)
git config user.name "infotinksy";
git config user.email "infotinksy@personal.org"
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git log ### this will show you the name of the AUTHOR (git log doesnt show COMMITER by default) to see name of the COMMITER run this: git log --pretty='%cn' -n1 HEAD
git cat-file -p HEAD ### this will show you the current AUTHOR and COMMITER
git log ### this will show you the name of the AUTHOR (git log doesnt show COMMITER by default) to see name of the COMMITER run this: git log --pretty='%cn' -n1 HEAD git cat-file -p HEAD ### this will show you the current AUTHOR and COMMITER
git log ### this will show you the name of the AUTHOR (git log doesnt show COMMITER by default) to see name of the COMMITER run this: git log --pretty='%cn' -n1 HEAD
git cat-file -p HEAD ### this will show you the current AUTHOR and COMMITER
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
### anyhow... we are just running the above commands to find out the AUTHOR (COMMITER is optional). the above advanced commands (git cat-file and git log --pretty) should just list us the FROM's/SOURCE's AUTHOR and COMMITER... We only need the AUTHOR of FROM/SOURCE.
### anyhow... we are just running the above commands to find out the AUTHOR (COMMITER is optional). the above advanced commands (git cat-file and git log --pretty) should just list us the FROM's/SOURCE's AUTHOR and COMMITER... We only need the AUTHOR of FROM/SOURCE.
### anyhow... we are just running the above commands to find out the AUTHOR (COMMITER is optional). the above advanced commands (git cat-file and git log --pretty) should just list us the FROM's/SOURCE's AUTHOR and COMMITER... We only need the AUTHOR of FROM/SOURCE.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
### Go thru every commit and change author and commiter of every commit done by author "infotinks" to author "Koss Bossy" & commiter name "infotinksy"
git filter-branch --commit-filter \
'if [ "$GIT_AUTHOR_NAME" = "infotinks" ]; then \
export GIT_AUTHOR_NAME="Koss Bossy";\
export GIT_AUTHOR_EMAIL=infotinksy@personal.org;\
export GIT_COMMITTER_NAME="Koss Bossy";\
export GIT_COMMITTER_EMAIL=infotinksy@personal.org;\
fi;\
git commit-tree "$@"'
### Go thru every commit and change author and commiter of every commit done by author "infotinks" to author "Koss Bossy" & commiter name "infotinksy" git filter-branch --commit-filter \ 'if [ "$GIT_AUTHOR_NAME" = "infotinks" ]; then \ export GIT_AUTHOR_NAME="Koss Bossy";\ export GIT_AUTHOR_EMAIL=infotinksy@personal.org;\ export GIT_COMMITTER_NAME="Koss Bossy";\ export GIT_COMMITTER_EMAIL=infotinksy@personal.org;\ fi;\ git commit-tree "$@"'
### Go thru every commit and change author and commiter of every commit done by author "infotinks" to author "Koss Bossy" & commiter name "infotinksy"
git filter-branch --commit-filter \
'if [ "$GIT_AUTHOR_NAME" = "infotinks" ]; then \
export GIT_AUTHOR_NAME="Koss Bossy";\
export GIT_AUTHOR_EMAIL=infotinksy@personal.org;\
export GIT_COMMITTER_NAME="Koss Bossy";\
export GIT_COMMITTER_EMAIL=infotinksy@personal.org;\
fi;\
git commit-tree "$@"'
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
### OPTIONAL - I didnt run this part ###
### go thru every commit. the ones that have infotinks as the commiter lets change those as well. This is optional because Im assuming where infotinks was the author, he was probably the commiter (apparently this usually the case, so we can skip this optional step, however in rare type of git use-cases: where you can submit commits as patches --- or commit from different pcs --- or have someone else commit code for you, then this might apply to you)
git filter-branch --commit-filter \
'if [ "$GIT_COMMITTER_NAME" = "infotinks" ]; then \
export GIT_AUTHOR_NAME="Koss Bossy";\
export GIT_AUTHOR_EMAIL=infotinksy@personal.org;\
export GIT_COMMITTER_NAME="Koss Bossy";\
export GIT_COMMITTER_EMAIL=infotinksy@personal.org;\
fi;\
git commit-tree "$@"'
### END OF OPTIONAL ###
### OPTIONAL - I didnt run this part ### ### go thru every commit. the ones that have infotinks as the commiter lets change those as well. This is optional because Im assuming where infotinks was the author, he was probably the commiter (apparently this usually the case, so we can skip this optional step, however in rare type of git use-cases: where you can submit commits as patches --- or commit from different pcs --- or have someone else commit code for you, then this might apply to you) git filter-branch --commit-filter \ 'if [ "$GIT_COMMITTER_NAME" = "infotinks" ]; then \ export GIT_AUTHOR_NAME="Koss Bossy";\ export GIT_AUTHOR_EMAIL=infotinksy@personal.org;\ export GIT_COMMITTER_NAME="Koss Bossy";\ export GIT_COMMITTER_EMAIL=infotinksy@personal.org;\ fi;\ git commit-tree "$@"' ### END OF OPTIONAL ###
### OPTIONAL - I didnt run this part ###
### go thru every commit. the ones that have infotinks as the commiter lets change those as well. This is optional because Im assuming where infotinks was the author, he was probably the commiter (apparently this usually the case, so we can skip this optional step, however in rare type of git use-cases: where you can submit commits as patches --- or commit from different pcs --- or have someone else commit code for you, then this might apply to you)
git filter-branch --commit-filter \
'if [ "$GIT_COMMITTER_NAME" = "infotinks" ]; then \
export GIT_AUTHOR_NAME="Koss Bossy";\
export GIT_AUTHOR_EMAIL=infotinksy@personal.org;\
export GIT_COMMITTER_NAME="Koss Bossy";\
export GIT_COMMITTER_EMAIL=infotinksy@personal.org;\
fi;\
git commit-tree "$@"'
### END OF OPTIONAL ###
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
### look at how our remote is configured.
$ git remote -v
origin https://github.com/infotinks/Test1.git (fetch)
origin https://github.com/infotinks/Test1.git (push)
### look at how our remote is configured. $ git remote -v origin https://github.com/infotinks/Test1.git (fetch) origin https://github.com/infotinks/Test1.git (push)
### look at how our remote is configured.
$ git remote -v
origin https://github.com/infotinks/Test1.git (fetch)
origin https://github.com/infotinks/Test1.git (push)
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
### remove origin
git remote remove origin
### remove origin git remote remove origin
### remove origin
git remote remove origin
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
### make sure its removes (should be blank)
git remote -v
### make sure its removes (should be blank) git remote -v
### make sure its removes (should be blank)
git remote -v
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
### login to github.personal.org and make a new repo called Test1
### set github.personal.org as new remote
git remote add origin https://github.personal.org/infotinksy/Test1.git
git push --set-upstream origin master
### login to github.personal.org and make a new repo called Test1 ### set github.personal.org as new remote git remote add origin https://github.personal.org/infotinksy/Test1.git git push --set-upstream origin master
### login to github.personal.org and make a new repo called Test1
### set github.personal.org as new remote
git remote add origin https://github.personal.org/infotinksy/Test1.git
git push --set-upstream origin master
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
### make sure your remotes are now pointing to github.personal.org $ git remote -v origin https://github.personal.org/infotinksy/Test1.git (fetch) origin https://github.personal.org/infotinksy/Test1.git (push)
### make sure your remotes are now pointing to github.personal.org $ git remote -v origin https://github.personal.org/infotinksy/Test1.git (fetch) origin https://github.personal.org/infotinksy/Test1.git (push)
### make sure your remotes are now pointing to github.personal.org $ git remote -v origin https://github.personal.org/infotinksy/Test1.git (fetch) origin https://github.personal.org/infotinksy/Test1.git (push)
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
### now "git pull" and "git push" will work to github.personal.org
### now "git pull" and "git push" will work to github.personal.org
### now "git pull" and "git push" will work to github.personal.org

The END.

Leave a Reply

Your email address will not be published. Required fields are marked *