Anil's CheatSheet for AS7 Development

Objective: Set up Marcus's GIT master as a remote repository


git remote add marcus 



Objective: Sync my branch with Marcus on a regular basis.


 git fetch marcus; git merge marcus/master --ff-only


Objective:  Bungled my master.  Need to recreate my master from jboss-as upstream master.

Solution #1:


git reset --hard upstream/master



anil@localhost:~/as7/jboss-as$ git reset --hard upstream/master
HEAD is now at 328151e changed jaas to security-domains



Solution #2:


git branch -D master
git fetch upstream
git checkout upstream/master 
git checkout -b master




anil@localhost:~/as7/jboss-as$ git branch -D master
Deleted branch master (was 4340a3b). 

anil@localhost:~/as7/jboss-as$ git fetch upstream
remote: Counting objects: 56, done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 44 (delta 8), reused 0 (delta 0)
Unpacking objects: 100% (44/44), done.
From git://
   b3e90b9..328151e  master     -> upstream/master

anil@localhost:~/as7/jboss-as$ git checkout upstream/master 
Previous HEAD position was 1504538... sync
HEAD is now at 328151e... changed jaas to security-domains

anil@localhost:~/as7/jboss-as$ git checkout -b master
Switched to a new branch 'master'
anil@localhost:~/as7/jboss-as$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#       .metadata/
nothing added to commit but untracked files present (use "git add" to track)


Objective  Your origin (fork of upstream jboss-as) is totally screwed up


Go to github dashboard and delete the repository.

After that, fork the upstream and follow the  guide.

Objective:  Cherry pick one of Marcus's commits


git cherry-pick b4e04f52046cad2687d60348bad3c8678ccd2963


b4e0   is the commit id



Objective:  you want to fork Marcus's branch and make some changes and send pull request


Assume Marcus has a branch called "jacc" that you want to work on and fix.

3 steps:

  • Remote add Marcus's repo.
  • Fetch Marcus's repo.
  • Checkout Marcus's branch into your own branch called "marcus"



$ git remote add mmoyses git://

$ git fetch mmoyses
remote: Counting objects: 404, done.
remote: Compressing objects: 100% (69/69), done.
remote: Total 183 (delta 93), reused 158 (delta 71)
Receiving objects: 100% (183/183), 36.44 KiB, done.
Resolving deltas: 100% (93/93), completed with 53 local objects.
From git://
 * [new branch]      ds         -> mmoyses/ds
 * [new branch]      infinispan_5_CR6 -> mmoyses/infinispan_5_CR6
 * [new branch]      jacc       -> mmoyses/jacc
 * [new branch]      master     -> mmoyses/master

$ git checkout -b marcus mmoyses/jacc 
Branch marcus set up to track remote branch jacc from mmoyses.
Switched to a new branch 'marcus'

$ git status
# On branch marcus
nothing to commit (working directory clean) 


General Chat that you may find useful

Topic:  Reset master, rebase etc


(03:34:03 PM) asaldhan: dmlloyd: if I reset my master,  I do not have to do a push?
(03:34:24 PM) dmlloyd: it depends on whether you want to also reset your remote to upstream/master
(03:34:37 PM) asaldhan: dmlloyd: yeah I want to reset basically.
(03:34:51 PM) dmlloyd: well if your remote was already reset to upstream then you don't need to
(03:34:59 PM) dmlloyd: usually a "git status" will tell you if you've diverted
(03:35:00 PM) asaldhan: dmlloyd: case when I have totally messed up my master.
(03:35:03 PM) dmlloyd: diverged*
(03:35:16 PM) dmlloyd: it's not like svn
(03:35:22 PM) dmlloyd: your local copy isn't a slave of the remote copy
(03:35:31 PM) dmlloyd: they're two isolated git repositories
(03:35:53 PM) dmlloyd: so if you haven't pushed anything to your origin/master in a while then it won't 
have changed without your knowledge
(03:35:57 PM) asaldhan: dmlloyd: right. but if I have checked in commits to my master and they are bogus.
(03:36:13 PM) dmlloyd: when you commit, it commits into the repository local to your machine
(03:36:22 PM) dmlloyd: your local checkout is a complete repository
(03:36:24 PM) asaldhan: dmlloyd: I meant pushed
(03:36:42 PM) asaldhan: dmlloyd: if I have pushed some changes to my master and they are screwed 
up in relation to upstream
(03:36:45 PM) dmlloyd: if you want to change your remote origin/master then yes pushing is what 
you want to do
(03:37:36 PM) asaldhan: dmlloyd: when I reset git reset --hard upstream/master
(03:37:41 PM) asaldhan: dmlloyd: what happened?
(03:37:49 PM) asaldhan: dmlloyd: local branch was replaced with upstream/master?
(03:37:57 PM) dmlloyd: you're changing your local master to point to the same commit as upstream/master
(03:38:19 PM) dmlloyd: where upstream/master is as of the last time you did "git fetch upstream"
(03:38:19 PM) asaldhan: dmlloyd: now I want my master to get synched with upstream/master.
(03:38:56 PM) dmlloyd: if you have local commits and you want to combine your local commits with 
upstream commits, use "git rebase upstream/master", which will put the new upstream commits 
chronologically before your local commits.
(03:39:09 PM) dmlloyd: well, sequentially before.  whatever.
(03:39:33 PM) asaldhan: Interactive rebase already started
(03:39:38 PM) asaldhan: dmlloyd: ^ whats that?
(03:39:46 PM) dmlloyd: that means you're in the middle of a rebase already.
(03:39:50 PM) dmlloyd: "git rebase --cancel"
(03:39:59 PM) dmlloyd: or maybe "--abort" I forget
(03:40:17 PM) dmlloyd: use "git log upstream/master..master" to see what you've got that 
upstream hasn't, and "git log master..upstream/master" to see what upstream's got that you haven't