- Building Enterprise JavaScript Applications
- Daniel Li
- 200字
- 2021-07-23 16:31:05
Pulling and pushing
Next, we need to update our local repository so it knows the address of the remote repository:
$ git remote add origin https://github.com/d4nyll/hobnob.git
$ git push -u origin master
Don't use https://github.com/d4nyll/hobnob.git; create your own remote repository instead.
If you get a fatal: Authentication failed for https://github.com/d4nyll/hobnob.git/ error, check that your GitHub username and password are entered properly. If you use two-factor authentication (2FA) on your GitHub account, you need to use an SSH key to push to the remote repository.
If you get a fatal: Authentication failed for https://github.com/d4nyll/hobnob.git/ error, check that your GitHub username and password are entered properly. If you use two-factor authentication (2FA) on your GitHub account, you need to use an SSH key to push to the remote repository.
The -u tag sets the upstream repository to be origin. Without it, we would have to specify which remote repository we want to push to or pull from every time we run git push and git pull; using the -u tag here will save us a lot of time in the future. Subsequent pushes and pulls can omit the -u tag.
By default, git push doesn't push tags to remote repositories. So, we'd have to push tags manually. The syntax for pushing tags is similar to that of pushing branches:
$ git push origin [tagname]
Alternatively, if you want to push all tags, you can run the following command instead:
$ git push origin --tags