Reputation: 3291
I have a project in remote server.
1)At home, I clone the project and then edit something in master and then push to remote.(What is the command?)
2)At company, I clone the project(before step1), now, i want to continue my task, so I want to update from remote. (What is the command?)
3)Then, after update, I create a new branch and work on new features, but not enough time, so I want to push to remote and continue my work at home. (What is the command?)
4)When I back home, I want to update my existing project from remote and continue my task. (What is the command?) And then I edit something and want to push to remote and continue my work at company. (What is the command?)
5)Then, I go back to company next day, I want to update from remote and continue my task.(What is the command?)
6)Finally, I have another computer A, I want to clone from remote and work on the branch.(What is the command?). After edit something, I want to push to remote. (What is the command?)
I am really a starter of git.
Step 4 ,5 and step 6 is the most difficult part as I don't know how to continue to work on a branch or clone project from remote and then work on the branch.
Please help me.
Upvotes: 1
Views: 1801
Reputation: 12609
Let's assume you use GitHub for hosting, you're called foo and your project's called bar.
Case 1. Clone and work at home
git clone [email protected]:foo/bar.git
cd bar
... edit
git commit -a
git push origin master
Case 2. At work
git fetch
git merge origin/master
Case 3. New branch at work
git checkout -b feature-1
... edit
git commit
git push origin feature-1
Case 4. Home, continue working on feature-1
git fetch
git checkout -t origin/feature-1
... edit
git commit
git push origin feature-1
Case 5. Work, continue working on feature-1
git fetch
git merge origin/feature-1
... continue
Case 6. Computer A
git clone [email protected]:foo/bar.git
cd bar
git checkout -t origin/feture-1
... edit
git commit
git push origin feature-1
I hope you get the idea. A few tricks:
git checkout -b XXX
creates a new branch XXX and checks it out in one stepgit checkout -t YYY/XXX
creates and checks out a local branch XXX which tracks branch XXX in remote YYY.Also make sure you learn the details for each command from the documentation. In other words don't follow my examples blindly.
Upvotes: 4
Reputation: 12958
First, I would highly recommend this reference:
http://git-scm.com/documentation
There are a number of ways to clone. Look at the chapter titled "Distributed Git". One way is like this:
git clone john@githost:simplegit.git
Assuming remote is named "origin"...
Upvotes: 2