John Doe
John Doe

Reputation: 9764

How do I commit a new project version on GitHub?

I'm new to GitHub and its terms confuse me a little. I made a commit. Now I want to change the project to a new refactored version.

  1. Do I need to delete files from the existing repo before commiting new version (if the structure was changed and some of the files are not needed anymore)?
  2. Do I need to push or to commit? Or do I need to do something else?

Upvotes: 0

Views: 654

Answers (2)

maček
maček

Reputation: 77778

Making a commit updates the repo on your local machine. Doing a push will replicate your repo changes on a remote.

You can commit as many times as you want locally. Once you are happy with the state of your repo, you can update the repo on Github with the following command:

git push origin master

If you want to delete a file from the repo, you can do this:

# remove the file
git rm path/to/my_file

# commit the remove to your local repo
git commit -m "removing my_file"

# update the remote (Github) repo with the removed file 
git push origin master

If the repo doesn't exist on Github yet, go ahead and create a repo there. They will give you step-by-step instructions on how to make your first commit. It will likely look something like this:

# go to project files
cd path/to/project

# initialize git repo
git init

# stage all project files in current directory to be committed
git add .

# make first commit
git commit -m "first commit"

# add the Github remote
git remote add origin <YOUR GITHUB URL>

# send repo to git
git push origin master

Upvotes: 1

artragis
artragis

Reputation: 3713

a commit to github is in two steps: ->first use command commit to save the changes localy ->then use push commande to save the changes on github

Upvotes: 1

Related Questions