I have a git repository that contains folders and files. And have locally a same folder as in git but a little bit changed files but not connected to git. How can i connect my local folder to the same git and commit all changes that i have done?
If your local folder is not a git repository, you should make it a repository first and commit your changes in a new branch then add a remote linking to your existing repository where you want to push your branch containing the changes.
$ cd path/to/your/local/directory
$ git init # make it a git repository
$ git checkout -b my_awesome_branch # checkout to a new branch containing your local changes
$ git add --all
$ git commit -m 'This should be a Message describing your local changes'
You will have all your local changes in git branch my_awesome_branch
. Now, You need to setup an upstream to remote repository where you will want to push this my_awesome_branch
.
$ git remote add my_awesome_upstream <your-upstream-git-repository-url>
$ git remote -v # To list remotes, and see if your remote is added correctly
$ git push my_awesome_upstream my_awesome_branch
Now, you can go to your remote repository and checkout to my_awesome_branch
from the UI in order to see your changes.
To merge the changes into the main branch(e.g. usually master
), you can open a merge/pull request against the main branch and review your changes before merging them to your main branch.
Hope it helps.
Let me know if any of the above is not clear. I will be in touch.
Resources:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With