Skip to content

Instantly share code, notes, and snippets.

@thinsoldier
Last active March 30, 2017 07:14
Show Gist options
  • Save thinsoldier/cf31cfa8eea97d31dc71cefccc86cc22 to your computer and use it in GitHub Desktop.
Save thinsoldier/cf31cfa8eea97d31dc71cefccc86cc22 to your computer and use it in GitHub Desktop.
Cloud9 c9 shankster bhavshashank showing how he could have sent his changes from zip file to github via Cloud9

2017-03-30

Log into c9.io and open one of your workspaces

Go to the terminal for that workspace.

Make a new folder:

mkdir shankster

Go into the new folder:

cd shankster

Make sure you are in the new folder:

pwd shankster

Download the zip file you uploaded to discord:

curl -Ok https://cdn.discordapp.com/attachments/294153614375649290/296876241129177088/phplearning.zip

Make sure the file was downloaded:

ll

Unzip the zip file:

unzip phplearning.zip

Make sure the file was unzipped to a new folder:

ll - You should see phplearning.zip file and phplearning folder

Go to your githup project: https://github.com/BhavShashank/phplearning

Click clone or download button.

Copy the git repo url: [email protected]:BhavShashank/phplearning.git

Go back to cloud9 terminal.

Download the github repo and save it to a folder named githubrepo:

git clone [email protected]:BhavShashank/phplearning.git githubrepo

Make sure the githubrepo folder was created:

ll - should see githubrepo/, phplearning/, phplearning.zip

Go into githubrepo folder:

cd githubrepo

Find out which branch is active and which branches were downloaded:

git branch - master branch is active

Show the history to make sure the master branch is on the commit I want it to be on:

git log --oneline

Yes, it looks like master is at the commit where you updated README.md

IMPORTANT NEW INFORMATION: The actual git repo and all the history is stored in a "hidden" folder named .git within the project folder.

ll - see the .git folder in the list.

make a folder named .git in the phplearning folder:

mkdir ../phplearning/.git

Copy the .git folder from the githubrepo folder to the phplearning folder:

cp -r .git/* ../phplearning/.git/

You have now turned the unzipped phplearning folder into a git repo. This new git repo only knows about the latest commit on the github origin repo. This means anything in unzipped folder that is different from the github repo master branch will need to be committed.

Go to the phplearning folder:

cd ../phplearning/
ll

Check that git functionality is working:

git log --oneline

List all files that are different from the last commit and all new files that are untracked:

git status

Show the changes in the files that are different from the last commit:

git diff

Add all changed files and all new files to be "staged":

git add .

Check to make sure everything is staged:

git status

I chose to change the current branch to something else since this is just an experiment:

git checkout -b experimentc9

Make sure the changes are still stages:

git status

Commit the changes:

git commit -m "all changes from zip file"

Push the experimentc9 branch to github and tell git to track it:

git push -u origin experimentc9

https://www.git-tower.com/learn/git/faq/track-remote-upstream-branch

You can now go to your github repo and switch the branch to experimentc9 to see that the changes from the zip you created at work are on github.

https://github.com/BhavShashank/phplearning


When you get home:

Fetch from github so the local repo is aware of everything new that exists in the github repo.

Check out the experimentc9 branch.

Now do these 2 commands:

git reset --soft master

git checkout master

The master branch will be active AND all the changes from your zip will exist in the project folder. They will be staged.

Unstage the changes then commit the changes little by little with good commit messages. These commits will happen on the master branch. You can now delete the experimentc9 branch and push master to github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment