5,597,501 Members 31,613 Now Online
XDA Developers Android and Mobile Development Forum

Using Git in an unusual workflow

Tip us?
 
kyomuga
Old
#1  
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: Feb 2011
Default Using Git in an unusual workflow

Hi people, this is my first post here, I think is the best place where I can discuss my programming issues. If this post isn't in the correct place, please move it and forgive my dumbness.

I'm working in some personal projects, android apps, in my house. There I have my PC with Eclipse and Git, at the end of the weekend I'm always commiting changes and uploading them to GitHub. When I go to my office, sometimes I have some spare time and I open Eclipse to start working, but of course I synchronize the GitHub repository data with my local data (in order to work with the latest changes I've made in my house), but I'm always having troubles with this action: I don't know how to discard my local old files, keep the files that haven't been modified and download the latest version of my modified files. I always end deleting the folder and cloning the repo again because I mess the files... I'm sure there is a better way.

So, I'd be delighted if you could assist me on how should I work with this feature of Git. I'd like too to take advice to improve my workflow. I've checked lots of sites and tutorials about Git but I haven't been able to get useful info to match with my workflow...

Thank you in advance
 
Androguide.fr
Old
(Last edited by Androguide.fr; 27th January 2014 at 08:38 PM.)
#2  
Androguide.fr's Avatar
Recognized Contributor
Thanks Meter 6632
Posts: 1,992
Join Date: Jul 2012
Location: Lyon, France

 
DONATE TO ME
Quote:
Originally Posted by kyomuga View Post
Hi people, this is my first post here, I think is the best place where I can discuss my programming issues. If this post isn't in the correct place, please move it and forgive my dumbness.

I'm working in some personal projects, android apps, in my house. There I have my PC with Eclipse and Git, at the end of the weekend I'm always commiting changes and uploading them to GitHub. When I go to my office, sometimes I have some spare time and I open Eclipse to start working, but of course I synchronize the GitHub repository data with my local data (in order to work with the latest changes I've made in my house), but I'm always having troubles with this action: I don't know how to discard my local old files, keep the files that haven't been modified and download the latest version of my modified files. I always end deleting the folder and cloning the repo again because I mess the files... I'm sure there is a better way.

So, I'd be delighted if you could assist me on how should I work with this feature of Git. I'd like too to take advice to improve my workflow. I've checked lots of sites and tutorials about Git but I haven't been able to get useful info to match with my workflow...

Thank you in advance
Hi, this should be the right section for talking git, don't worry
My understanding is that you have some local (uncommited) changes on your machine at work, and you want to pull the latest commits from your distant repository while avoiding merge conflicts, is that correct ?

If it is, then you have several solutions at your disposal:
  • The easiest and cleanest way is to stash your local changes, pull the new commits and then pop the stashed changes to commit them over the up-to-date repo later on:
    (replace <remote> and <branch> with your actual remote and target branch, for example git pull origin master)
    Code:
    git stash
    git pull <remote> <branch>
    git stash pop
    The branch is now up to date and your local changes are still there for you to commit or to continue modifying.
    If instead you decide that you don't need the local changes you stashed anymore, instead of popping them you can clear the stash:
    Code:
    git stash clear
    If you want to fetch remote changes for all the branches, replace the git pull with:
    Code:
    git fetch <remote>
  • If all you want is to get rid of your local changes and sync with upstream repo, you can use:
    Code:
    git checkout .
    git pull <remote> <branch>

Hope this helps, let me know if you need further help, or if I didn't understand your question properly

Quote:
My Contributions
(Apps, Librairies, Roms & Guides)
 

Pimp My Rom: Website / App / Thread

dSploit: Website / Github

Flash Gordon (Flash zips without a recovery): Thread

Universal init.d: App

PlayView/CardsUI Library: Portal / Github

HoloGraph Library: Portal / Github

Ubuntu Touch for i9300: Thread

Omni nightlies for Xperia Z1: Thread

Paranoid Android builds: Thread

Revive your bricked p68xx : Guide
Follow me on Github
The Following User Says Thank You to Androguide.fr For This Useful Post: [ Click to Expand ]
 
kyomuga
Old
(Last edited by kyomuga; 28th January 2014 at 08:14 AM.)
#3  
Junior Member - OP
Thanks Meter 0
Posts: 2
Join Date: Feb 2011
Quote:
Originally Posted by Androguide.fr View Post

If all you want is to get rid of your local changes and sync with upstream repo, you can use:
Code:
git checkout .
git pull <remote> <branch>
Thank you very much. This is what I need, or at least what fits best with my workflow, as I'm always starting programming from the point i've stopped working in another place, being like this:
  • When I get to work:
    Code:
    git checkout .
    git pull <remote> <branch>
    So I'm getting my updated code as I stopped programming at home
  • Minutes after going home:
    Code:
    git add .
    git commit -m "another day, another commit"
    git push origin master
  • When I get home:
    Code:
    git checkout .
    git pull <remote> <branch>
    So I'm getting my updated code as I stopped programming at work
  • Minutes after going to bed:
    Code:
    git add .
    git commit -m "another day, another commit"
    git push origin master
This is a correct workflow? or I'm misusing the benefits of Git?
 
Androguide.fr
Old
#4  
Androguide.fr's Avatar
Recognized Contributor
Thanks Meter 6632
Posts: 1,992
Join Date: Jul 2012
Location: Lyon, France

 
DONATE TO ME
Quote:
Originally Posted by kyomuga View Post
Thank you very much. This is what I need, or at least what fits best with my workflow, as I'm always starting programming from the point i've stopped working in another place, being like this:
  • When I get to work:
    Code:
    git checkout .
    git pull <remote> <branch>
    So I'm getting my updated code as I stopped programming at home
  • Minutes after going home:
    Code:
    git add .
    git commit -m "another day, another commit"
    git push origin master
  • When I get home:
    Code:
    git checkout .
    git pull <remote> <branch>
    So I'm getting my updated code as I stopped programming at work
  • Minutes after going to bed:
    Code:
    git add .
    git commit -m "another day, another commit"
    git push origin master
This is a correct workflow? or I'm misusing the benefits of Git?
Yeah, this looks correct, as long as you don't need your local changes this is probably the best way.

Quote:
My Contributions
(Apps, Librairies, Roms & Guides)
 

Pimp My Rom: Website / App / Thread

dSploit: Website / Github

Flash Gordon (Flash zips without a recovery): Thread

Universal init.d: App

PlayView/CardsUI Library: Portal / Github

HoloGraph Library: Portal / Github

Ubuntu Touch for i9300: Thread

Omni nightlies for Xperia Z1: Thread

Paranoid Android builds: Thread

Revive your bricked p68xx : Guide
Follow me on Github
The Following User Says Thank You to Androguide.fr For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes