Post Reply

Using Git in an unusual workflow

OP kyomuga

27th January 2014, 09:12 AM   |  #1  
OP Junior Member
Thanks Meter: 0
 
2 posts
Join Date:Joined: Feb 2011
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
27th January 2014, 08:28 PM   |  #2  
Androguide.fr's Avatar
Recognized Contributor
Flag Lyon, France
Thanks Meter: 6,987
 
2,053 posts
Join Date:Joined: Jul 2012
Donate to Me
More
Quote:
Originally Posted by kyomuga

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
Last edited by Androguide.fr; 27th January 2014 at 08:38 PM.
The Following User Says Thank You to Androguide.fr For This Useful Post: [ View ]
28th January 2014, 08:06 AM   |  #3  
OP Junior Member
Thanks Meter: 0
 
2 posts
Join Date:Joined: Feb 2011
Quote:
Originally Posted by Androguide.fr


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?
Last edited by kyomuga; 28th January 2014 at 08:14 AM.
28th January 2014, 09:44 AM   |  #4  
Androguide.fr's Avatar
Recognized Contributor
Flag Lyon, France
Thanks Meter: 6,987
 
2,053 posts
Join Date:Joined: Jul 2012
Donate to Me
More
Quote:
Originally Posted by kyomuga

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.
The Following User Says Thank You to Androguide.fr For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in IDEs, Libraries, & Programming Tools by ThreadRank