How to push changes to Git Hub using the command line?
Using Command line to PUSH to GitHub
1. Creating a new repository
- You need to create a new repository and click on the plus sign.
- Fill up all the required details, i.e., repository name, description and also make the repository public this time as it is free.
2. Open your Git Bash
3. Create your local project in your desktop directed towards a current working directory.
4. Initialize the git repository
- Use
git init
to initialize the repository. It is used to create a new empty repository or directory consisting of files' with the hidden directory. '.git' is created at the top level of your project, which places all of the revision information in one place.
5. Add the file to the new local repository
- Use
git add .
in your bash to add all the files to the given folder. - Use
git status
in your bash to view all the files which are going to be staged to the first commit.
6. Commit the files staged in your local repository by writing a commit message
- You can create a commit message by
git commit -m 'your message'
, which adds the change to the local repository. git commit
uses '-m' as a flag for a message to set the commits with the content where the full description is included, and a message is written in an imperative sentence up to 50 characters long and defining "what was changed", and "why was the change made".
7. Copy your remote repository's URL from GitHub
- The HTTPS or URL is copied from the given GitHub account, which is the place of the remote repository.
8. Add the URL copied, which is your remote repository to where your local content from your repository is pushed
git remote add origin 'your_url_name'
- In the above code, The 'origin' is the remote name, and the remote URL is "https://github.com/Olivia-Smithcoder100/FaceDetection.git". You can see the remote as GitHub in this case, and GitHub provides the URL for adding to the remote repository.
9. Push the code in your local repository to GitHub
git push -u origin master
is used for pushing local content to GitHub.- In the code, the origin is your default remote repository name and '-u' flag is upstream, which is equivalent to '-set-upstream.' and the master is the branch, name.upstream is the repository that we have cloned the project.
- Fill in your GitHub username and password.
10. View your files in your repository hosted on GitHub
- You can finally see the file hosted on GitHub.
Comments
Post a Comment