简体   繁体   中英

git: uploading changes to cloned remote repository

I am new to Git, coming from SubVersion.

I have a main development desktop computer where my Android app is stored with eclipse's E-GIT. I am currently working away from it, working from my laptop, so I configured E-Git via SSH .

  • I'm using eclipse-egit in both places , so never really dealt with command-line git and its thousand options.
  • The clone process was automatically done by eclipse's " import git project " without problems, after setting up ssh keys, etc..

Now I've been doing a lot of work (like 300 commits) in my cloned git (the laptop) and will return to my office to resume work in my Main server. and I have a couple questions:

  • 1 Everytime I press "Team>Commit" in my laptop, are the commits uploaded to my main desktop git? -it's online 24x7, e-git ssh configured, etc-

  • 2 I suppose the answer to 1- is no . Do I have to press "Team>Push to UpStream" to do it? Or what option would do that?

I've been reading an answer here Downloading remote / Uploading locale repository and removing any obsolete files that suggests creating kind of a bare intermediate repository, but don't understand very well if this applies to my case, because they talk about branches and other stuff while I don't have any, just one normal repo with a master branch that was cloned in my laptop.

I am a little scared because it's the first time I'm doing this, been 2 months out of office, and don't want to risk losing thousands of changes.

Rather than uploading your commits from your laptop, you could download them from your main computer.

Said differently: just add on your main computer, the repo on your laptop as a remote. Then, just pull from it.

I don't know E-git, but I guess it shouldn't be much different from what you did to clone on your laptop. From the command line it would just looks like

git remote add myLaptop ssh me@laptop:/path/to/repo
git pull myLaptop master

Edit to answer the comment:

You'll add a remote to your existing repo. Hence you won't create a new one.

To get a better understanding of remotes, you might want to read http://git-scm.com/book/ch2-5.html and http://git-scm.com/book/en/Git-Branching-Remote-Branches


Edit to answer the other comment:

If you have conflicts and if you're sure you don't care about the files on your main computer, you could run, from your main computer:

#Discard your un-commited local changes, to avoid git complaining about conflicts
#*Beware* you won't discard changes you're actually interested in!
git reset --hard

#Retrieve the commit from the laptop
git fetch myLaptop

#Checkout the master branch of your laptop
git checkout myLaptop/master

#Move your master on this commit
#*Beware* if your laptop master and main computer master branches diverged, you may lose commits
git checkout -B master

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM