Jump to content

A Basic Modder's Guide to Git and Github


Recommended Posts

@Luke 

1. Open VSCode Settings and enable 'Extensions > Git > Allow Force Push'

2. Use git log --oneline to get 'shortID' of the git commit hash:

image.png.b1dca46555cf03aa00ec93d9326f536e.png

3. Type git reset --hard 'shortID'

Please remember that this will set the local files to the exact content of the commit!

4. Click Push (Force) from the "Pull, Push" submenu

image.png.80fe1dc317d0f95f5f51fdddae43ac6c.png

This will completely overwrite remote repository to the state of local copy - there is no truing back after this point! No backup!

I recommend you to install GitLens extension - it might look like overkill but you can ignore almost all of the advanced stuff and focus on this nice view:

image.png.332c30dfdd5d4bcc11eb9ded13be281f.png

Edited by AL|EN
Link to comment

@AL|EN

It worked! So, a couple of questions:

  • Is this the extension you were talking about?
  • Do you recommend signing commits locally using GPG? I've been using it for some time, the only thing I don't like is that past commits become "unverified" when a certain key expires, which is kinda misleading/unintended...
  • Is there a way to update Git in Terminal instead of downloading the new version from its site?

Thanks for your time.

Edited by Luke
Link to comment

@Luke 

- yes
- just forget about it, or use something else than VSCode only for git-related tasks (I recommend SmartGit but GitHub Desktop should be enough for simple workflow)
- you don't have to update git at all, there are no major features which are worth user attention, Windows version should have checkbox for 'auto-updater' which will notify you and install new version automatically.

For manual install:

  1. If you have Windows 10 then install 'winget' and then use
     winget install 'Git' --silent
  2.  If you have Windows 7, install https://chocolatey.org/install#individual and follow instruction regarding how to install packages

Hope that this helps.

Link to comment

@AL|EN

I see, will use "changelog.md" then...

Separately, I'm having some troubles syncing forks. My fork is 5 commits behind (and 0 commits ahead of) the original project, but git fetch upstream does nothing...

If I execute "git remote -v", it returns

origin  https://github.com/MY_USERNAME/MY_FORK.git (fetch)
origin  https://github.com/MY_USERNAME/MY_FORK.git (push)
upstream        https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
upstream        https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)

so I don't know what I'm missing...

Edited by Luke
Link to comment

@Luke 

git sync fork with upstream:

https://stackoverflow.com/questions/20984802/how-can-i-keep-my-fork-in-sync-without-adding-a-separate-remote/21131381#21131381 - this post show you how to do it 'directly on the Github.com website'. After last step (Rebase and Merge), when they aren't any conflicts, you simply pull the updates which are now also inside your online fork into you local repository.

Link to comment
11 minutes ago, AL|EN said:

@Luke 

git sync fork with upstream:

https://stackoverflow.com/questions/20984802/how-can-i-keep-my-fork-in-sync-without-adding-a-separate-remote/21131381#21131381 - this post show you how to do it 'directly on the Github.com website'. After last step (Rebase and Merge), when they aren't any conflicts, you simply pull the updates which are now also inside your online fork into you local repository.

After clicking on "Rebase and Merge", my fork is now 4 commits ahead, 5 commits behind the original project... Guess there is still something wrong, right?

Link to comment
9 hours ago, Luke said:

Separately, I'm having some troubles syncing forks. My fork is 5 commits behind (and 0 commits ahead of) the original project, but git fetch upstream does nothing...

Fetching is just one of the first steps in the link you posted.  You then have to merge the changes into your current branch.  If you're dealing with the master branch, the command would be:

git merge upstream/master
Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...