B
B
Bags2016-03-31 08:55:52
git
Bags, 2016-03-31 08:55:52

How to work with Git on two computers from one account?

I know that everything is quite simple and easy to google, but still I'm confused.
There are two computers: work and home. I work with both. What commands to use so that there are no errors?
At work, I write code, commit, push to a remote repository on gitlab. I come home, git pull -> everything is downloaded to the local rep. I work, I push. Everything is in the master. Correctly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MagnetonBora, 2016-03-31
@MagnetonBora

It doesn't matter how many computers you work on. You write code on one, commit, then push.

git add my_file.txt
git commit -m 'Updates'
git push origin <branch_name>

On another computer:
git fetch -p
git pull origin <branch_name>

Or if you have not made any changes on your home computer, then you can do this:
git fetch -p
git reset --hard origin <branch_name>

or so
git fetch -p
git rebase origin <branch_name>

Then, after writing the code on this computer, you commit and push.

Z
Zakharov Alexander, 2016-03-31
@AlexZaharow

It seems everything is ok. The situation is similar to that if you had this repository lying on one computer in several different directories.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question