Do I push the solution or just what I changed? - c++

I changed one file in my project, LoginLogout.cpp. What should I be pushing if all I changed was LoginLogout.cpp? Do I need to re-push the solution also?

If all you changed is LoginLogout.cpp, then you only need to add that file to your new commit by doing git add LoginLogout.cpp. This will only add that file to your staging area, which you can then commit with git commit -m "changed LoginLogout.cpp" for example.
After that you just need to push this commit to your repo with git push which uploads all local branch commits to the corresponding remote branch.

Related

Github Pages not found after renaming repository

I was publishing user pages with GitHub pages. After renaming my repository from username.github.io to username.github.io__, and renaming back my repo to username.github.io my pages are not showing up anymore.
The purpose of renaming my repo was to unpublish my pages for a short period of time.
Can someone give me a solution to republish my pages?
It was just needed to update with empty commit :
git commit -m 'rebuild pages' --allow-empty
git push
While an extra commit solves the problem, you should note a few things.
First, to fix the issue, push a new commit.
git commit --allow-empty -m "Empty commit"
git push
Second, make sure that the branch you committed is the master branch. For example, in my case, I make changes to the develop branch, and then I had to merge develop to master so that the actual page gets built again.

Git pushing codes From repository 1 To repository 2(collaborator repository)

I need some help because I have some codes that I pulled from my repository branch and changed a couple of things in it.
What I need is to push it into another repository that I have been a collaborator in.
Been trying to push the codes, and trying to access it but to no avail.
Can anybody help me with this one? Any help will be greatly appreciated.
You have two different repositories where you manage to code. First one from where you clone/pull code and made some changes. Second one is what, where you want to push your latest code.
If you clone your repository from GIT then It automatically attach its GIT Url into your application. To check run this command
git remote -v
Result:
origin https://username#github.com/project-name.git (fetch)
origin https://username#github.com/project-name.git (push)
This is url from where you clone/pull your latest code. Now we have created alias of URL as ORIGIN.
so when ever you want to push your code, you will do
git push origin master
Now Add another GIT URL(remote) where you want to push your latest code.
git remote add origin_two https://username-two#github.com/project-name.git
So now commit your changes and made a pull request from your secondary GIT URL this way.
git pull origin_two master
If you got any conflicts then make corrections in code and then again add untracked files using
git add file-name
add a commit message
git commit -m "Your message"
and push your code to git
git push origin_two master
If you are working with branches:
You have two repositories now for a single application. So for that each repo has their own branches, to list down branches for each origin just follow
git branch -a
will list all the branches from two remotes. now If you really want to push on any other branch then you should commit all the changes on current branch an then move to your favorable branch using command
git branch branch-name
and do code here whatever code you will change now push to particular branch
git push origin_two branch-name
That's it :) Hope this can help you.

Add an existing origin to a django project and pull the existing repo in it.

I am new to GIT hub version Controlling System.
I am working on a project which i downloaded as zip from GIT hub. It is not a git repository. What i want to do is that I want to make it a git repository and want to pull the existing git repository in it when issuing a git pull command.
I want to create my own Development Branch, develop code on local, push code to github, then do a pull request
Help will be highly appreciated.
Since you don't have any history of your changes to preserve I think your best bet is to clone the repo normally, and then copy your changes into that repository. Your question is a bit sparse on details, but something like the following should work
git clone <git hub project> <new folder on your system>
# maybe you can use a tag here for the SHA
git checkout -b my_branch SHA_THAT_REPRESENTS_YOUR_ZIP_DOWNLOAD
cp -r <your existing directory> <your new git repository>
git status # abort if this step doesn't look right
git add # add all your changed files
git commit # commit your work
git rebase <main dev branch> # catch up

Unable to push local changes live using Git Push Heroku Master

I'm new to GitHub and have gotten myself into a tangle. I've been successfully deploying code to a Heroku / Django app. However, my last commit was unsuccessful. This is my flow...
- Git add .
- Git commit -m "social media icons"
- Git push heroku master
The last command returns....
Fetching repository, done.
Everything up-to-date
Everything is not up to date. One thing I've discovered on my GitHub app is that I have 2 branches "production" and "master". Master was last updated Sept 8th. I've run a few commands including "git pull origin master" and "git push -f" based on other Stack answers. The latter did seem to push something but not the changes in local. Sorry, I'm trying to find my feet here!
If you're on production branch then you will need to do
git push heroku production:master
Heroku will only deploy the master branch so this command is you pushing your local production branch into the master branch on the remote.
So you are on branch production but your other branch master is up to date. If you want to push the current branch you are on, you should explicitly say so: git push heroku production.
I would highly advise you to try git, it's an excellent resource.

Why is git not pushing contents of a folder?

After copying a folder 'myapp' into to my working folder, I do the following to add it to my staging area:
git add .
and then commit the changes:
git commit
Then I push my changes to Heroku:
git push heroku master
So my folder, called 'myapp' is present on heroku, but the problem is that it's completely empty.
When I do the following,
git clone myapp myapp2
the folder clones properly on my local machine with all expected subcontents.
Does anyone know why the subfolders' contents are not being pushed to Heroku properly? What am I doing wrong?
To answer the questions below:
I am doing the git add . in my top level folder (the folder that contains folder myapp). Doing git status shows `no changes added to commit (use "git add" and/or "git commit -a")
Yes, myapp contains files/folders (my django project)
I deleted my .gitignore file because I placed my virtual environment in another place altogeher so it's no longer in my project folder so I don't think that's affecting it.
Ok, I seemed to have solved the problem. Somehow git got in a weird state. I don't really understand how, but for some reason it wasn't adding any of the files in the folder.
I simply copied that folder and gave it a new name, and then followed the exact same process I had been doing all along, and it finally uploaded properly.
By default, you cannot push changes to a checked-out branch of a repository. It usually causes major problems! Here is what usually happens:
$ git push heroku master
...error messages...
To heroku
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'heroku'
Since you haven't mentioned any error messages, I'm assuming that you've added the following to your heroku repository configuration, or you're running a fairly old version of Git:
[receive]
denyCurrentBranch = false
It sounds like you want to check out a fresh copy of the master branch whenever you push a new version to your heroku repository. That can be achieved with a post-receive hook. Create a file in your heroku repository .git/hooks/post-receive, and give it +x permissions.
#!/bin/sh
while read oldrev newrev refname
do
if test "$refname" = refs/heads/master
then
( cd ..; GIT_DIR=.git; git reset --hard )
fi
done
Now, whenever you push a new master branch to heroku, the hook will run and check out the new branch. There are better ways to do this kind of thing, but this is simple.
Summary: By default, when you push changes, it only changes the history but not the working tree. The assumption is that someone might be working on that tree, so doing anything to it could be destructive.