Git Command Line
I am so used to using Github Desktop, but it's a little 'weird' if you don't know how to use git command line. So play with it right now!
I already have a project in my local, and I want to add it to Github.
cd <project directory> git init
This creates a subdirectory named .git that contains all of the repository files.
- Add the files to my new local repository.
git add .
- Commit the files in my local repository.
git commit -m 'initial version'
- Add the URL for the remote repository.
git remote add origin https://github.com/Yifan127/LearnPythonTheHardWay.git
- Verify the remote URL
git remote -v
- Push the changes in my local repository to Github.
git push origin master
- I want to rename the remote name
to a more meanningful one . git remote rename origin LPTHW
- I forked a repository in Github, and I find there are some updates in the upstream repository, then I want to sync my forked repository with the upstream repository.
git remote add Py103 https://github.com/Yifan127/Py103.git git remote add AIMinder https://github.com/AIMinder/Py103.git git remote -v
- Fetch the update from upstream repository to local master branch.
git fetch AIMinder
- Swith to master branch.
git checkout master
- Merge the changes from upstream with local master branch.
git merge AIMinder/master
- All the operations above are in my local repository, so at last I need to push the update to my remote Github repository.
git push Py103 master