Thursday, February 4, 2016

Lesson 61: git ignore all non .java files

Updated guide to gitignore in Android studio. To untrack every file that is now in your .gitignore
  1. Commit all changes to our code (the .java files)
  2. run git rm -r --cached . to remove any changed files from the index(staging area)
  3. run git add .
  4. Commit it, run git commit -m “commit message”
  5. Done

Note:
  • don’t forget to add dot “.” at the end of the command to indicate all files.
  • the correct git ignore filename is “.gitignore” (with dot at the beginning of the filename)

Example of working .gitignore file :
.idea/
.gradle/
*.iml
*.class
build/
local.properties
app/app.iml
ipekinjector/ipekinjector.iml
merchantapp/merchantapp.iml
zBarScannerLibrary/zBarScannerLibrary.iml
cashlezmpos/cashlezmpos.iml

For reference:


For java project I think all you need is add *.class in the gitignore file

Tuesday, January 19, 2016

Lesson 60: need to ignore files on Android Studio

There is NO NEED to add to the source control any of the following:
.idea/
.gradle/
*.iml
build/
local.properties
app/app.iml
http://stackoverflow.com/questions/16736856/what-should-be-in-my-gitignore-for-an-android-studio-project#17803964
answer by: reala valoro
UPDATE:
http://stackoverflow.com/questions/26363025/gitignore-misc-xml-and-iml-with-android-studio-0-8-9/26363300#26363300

Friday, October 23, 2015

Lesson 59: Change Git Remote URL

step 0:
buka program git bash


step 1:


step 2:
git remote show origin

(kalo sudah terhubung diminta user name &password, sbelumnya kalo masih di port 80 muncul error unable to access)

Saturday, October 17, 2015

Wednesday, August 26, 2015

Lesson 57: Rollback Git to past commit

1. git log
This is useful for view all the Commit history
https://git-scm.com/book/tr/v2/Git-Basics-Viewing-the-Commit-History

2. git reset --hard <tag/branch/commit id>
Enter the commit id to the end of the command
http://stackoverflow.com/questions/1616957/how-do-you-roll-back-reset-a-git-repository-to-a-particular-commit


Friday, August 21, 2015

Lesson 56: "Your branch and 'origin/master' have diverged

The option it to either to 'merge' or 'rebase', please take a look at this link below:
http://stackoverflow.com/questions/2452226/master-branch-and-origin-master-have-diverged-how-to-undiverge-branches

Personally, I'd go for 'rebase' as Jeff said in the answer.
26 
+1 for git pull --rebase –  Jeffrey Jose Apr 9 '11 at 15:16

Lesson 55: git rm -cached, git assume unchanged, and git reset

Important:
It is recommeded to use git rm -r --cached <file/directory>
You dont want to track specific gradle / android studio file, because others will always generate different according to their development environment.
for all files mentioned in .gitignore you can use this command:

git rm -r --cached .
 source:
http://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository

------
http://stackoverflow.com/questions/9750606/git-still-shows-files-as-modified-after-adding-to-gitignore

effect: files stay on local, but deleted on repo
example command:
git rm -r --cached .idea/
git rm -r --cached *.class

http://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository

vs

http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html

effect: files not comming, removed from (Git) index
example command:
git update-index --assume-unchanged <file>

UPDATE: to view list of assume unchanged files use this command:
git ls-files -v | grep ^[a-z]

--------------------------------------------------------------

UPDATE 2: git rm vs git reset
Well, no, a git rm has not the same behavior as a [git reset][8].
Both will affect the index, but:

  • one (the git rm) will record a file for deletion on the next commit, hence the 'deleted' status,
  • the other (git reset) will copy HEAD to the index, resetting said index back to what the file was in HEAD.

http://stackoverflow.com/questions/15455686/git-rm-cached-and-deleted-status